-
Notifications
You must be signed in to change notification settings - Fork 64
perf: Use 4x faster decimal conversion method across all indicators #439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
13
commits into
main
Choose a base branch
from
copilot/fix-392
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fdb9dff
Initial plan
Copilot afd8571
Add alternative decimal conversion method and comprehensive research
Copilot a7f42f8
Update all indicators to use faster decimal conversion method
Copilot 6529ffb
Final verification - all indicators now use 4x faster conversion method
Copilot 1c01662
refactor: Improve code formatting and readability across multiple ind…
DaveSkender 092a890
Merge main branch and resolve conflicts for decimal conversion perfor…
Copilot f96030e
Fix linting issues after merge
Copilot 2d526f0
Merge origin/main into copilot/fix-392
DaveSkender f268389
test: Update precision expectations for double-based decimal conversion
DaveSkender c1b6c8d
refactor: update function overloads to use pass statement
DaveSkender ba7f71e
docs: update performance benchmarks for v1.3.0
DaveSkender b714b93
Merge branch 'main' into copilot/fix-392
DaveSkender df4acd0
code review fixes
DaveSkender File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| """Benchmarks comparing performance of different decimal conversion methods.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from stock_indicators._cstypes import Decimal as CsDecimal | ||
| from stock_indicators._cstypes.decimal import to_pydecimal, to_pydecimal_via_double | ||
|
|
||
|
|
||
| @pytest.mark.performance | ||
| class TestDecimalConversionPerformance: | ||
| """Benchmark performance of different decimal conversion methods.""" | ||
|
|
||
| def test_benchmark_string_conversion(self, benchmark, raw_data): | ||
| """Benchmark the current string-based conversion method.""" | ||
| raw_data = raw_data * 100 # Use subset for faster testing | ||
|
|
||
| # Pre-convert to CsDecimal to isolate the conversion performance | ||
| cs_decimals = [CsDecimal(row[2]) for row in raw_data] | ||
|
|
||
| def convert_via_string(cs_decimals): | ||
| for cs_decimal in cs_decimals: | ||
| to_pydecimal(cs_decimal) | ||
|
|
||
| benchmark(convert_via_string, cs_decimals) | ||
|
|
||
| def test_benchmark_double_conversion(self, benchmark, raw_data): | ||
| """Benchmark the new double-based conversion method.""" | ||
| raw_data = raw_data * 100 # Use subset for faster testing | ||
|
|
||
| # Pre-convert to CsDecimal to isolate the conversion performance | ||
| cs_decimals = [CsDecimal(row[2]) for row in raw_data] | ||
|
|
||
| def convert_via_double(cs_decimals): | ||
| for cs_decimal in cs_decimals: | ||
| to_pydecimal_via_double(cs_decimal) | ||
|
|
||
| benchmark(convert_via_double, cs_decimals) | ||
|
|
||
| def test_benchmark_small_dataset_string_conversion(self, benchmark): | ||
| """Benchmark string conversion with a controlled small dataset.""" | ||
| test_values = [ | ||
| 1996.1012, | ||
| 123.456789, | ||
| 0.123456789, | ||
| 999999.999999, | ||
| 0.000001, | ||
| 1000000.0, | ||
| 1.8e-05, | ||
| 1.234e10, | ||
| ] * 1000 # Repeat to get meaningful measurements | ||
|
|
||
| cs_decimals = [CsDecimal(val) for val in test_values] | ||
|
|
||
| def convert_via_string(cs_decimals): | ||
| for cs_decimal in cs_decimals: | ||
| to_pydecimal(cs_decimal) | ||
|
|
||
| benchmark(convert_via_string, cs_decimals) | ||
|
|
||
| def test_benchmark_small_dataset_double_conversion(self, benchmark): | ||
| """Benchmark double conversion with a controlled small dataset.""" | ||
| test_values = [ | ||
| 1996.1012, | ||
| 123.456789, | ||
| 0.123456789, | ||
| 999999.999999, | ||
| 0.000001, | ||
| 1000000.0, | ||
| 1.8e-05, | ||
| 1.234e10, | ||
| ] * 1000 # Repeat to get meaningful measurements | ||
|
|
||
| cs_decimals = [CsDecimal(val) for val in test_values] | ||
|
|
||
| def convert_via_double(cs_decimals): | ||
| for cs_decimal in cs_decimals: | ||
| to_pydecimal_via_double(cs_decimal) | ||
|
|
||
| benchmark(convert_via_double, cs_decimals) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix markdown formatting issues.
The static analysis tool has identified several markdown formatting violations that should be addressed:
###headings should be##since they follow an#heading.🔎 Recommended markdown structure fixes
-### Indicators and conversions
+
+## Indicators and conversions
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
12-12: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
18-18: Link fragments should be valid
(MD051, link-fragments)
12-12: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
11-11: Blank line inside blockquote
(MD028, no-blanks-blockquote)
13-13: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
20-20: Link fragments should be valid
(MD051, link-fragments)
12-12: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
18-18: Link fragments should be valid
(MD051, link-fragments)
11-11: Blank line inside blockquote
(MD028, no-blanks-blockquote)
18-18: Link fragments should be valid
(MD051, link-fragments)
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot fix this and all code+markdown linting, builds, and tests cleanly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.