Skip to content
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

Improve Character method performance #340

Merged
merged 1 commit into from
Sep 24, 2022

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Sep 24, 2022

  • use pre-calculated answers for chars, generate using a test case using old methods
  • use HexConverter borrowed from .NET sources which has superior check performance for common case

We are mostly interested in normal ASCII range in the new benchmark (FullRange = false), which is the common case for parsing.

FileParsingBenchmark

Diff Method FileName Mean Error Gen 0 Gen 1 Allocated
Old ParseProgram angular-1.2.5 8,674.9 μs 7.81 μs 250.0000 109.3750 4,315 KB
New 8,684.2 μs (0%) 45.42 μs 250.0000 (0%) 109.3750 (0%) 4,315 KB (0%)
Old ParseProgram backbone-1.1.0 1,170.2 μs 4.28 μs 41.0156 19.5313 676 KB
New 1,152.6 μs (-2%) 3.39 μs 41.0156 (0%) 19.5313 (0%) 676 KB (0%)
Old ParseProgram jquery-1.9.1 6,858.5 μs 10.11 μs 226.5625 78.1250 3,764 KB
New 6,740.3 μs (-2%) 14.19 μs 226.5625 (0%) 78.1250 (0%) 3,764 KB (0%)
Old ParseProgram jquery.mobile-1.4.2 10,638.7 μs 31.19 μs 343.7500 171.8750 5,798 KB
New 10,197.7 μs (-4%) 54.15 μs 343.7500 (0%) 171.8750 (0%) 5,798 KB (0%)
Old ParseProgram mootools-1.4.5 5,528.6 μs 20.89 μs 187.5000 78.1250 3,091 KB
New 5,435.6 μs (-2%) 11.80 μs 187.5000 (0%) 78.1250 (0%) 3,091 KB (0%)
Old ParseProgram underscore-1.5.2 995.5 μs 3.69 μs 33.2031 13.6719 571 KB
New 968.0 μs (-3%) 3.38 μs 33.2031 (0%) 13.6719 (0%) 571 KB (0%)
Old ParseProgram yui-3.12.0 5,002.1 μs 11.92 μs 171.8750 70.3125 2,856 KB
New 4,857.4 μs (-3%) 14.13 μs 171.8750 (0%) 70.3125 (0%) 2,856 KB (0%)

CharBenchmark

Method FullRange Mean Error StdDev Gen 0 Allocated
IsHexDigit_Old False 245.26 ns 0.424 ns 0.397 ns - -
IsHexDigit_New False 28.56 ns 0.061 ns 0.057 ns - -
IsDecimalDigit_Old False 28.89 ns 0.070 ns 0.062 ns - -
IsDecimalDigit_New False 28.55 ns 0.071 ns 0.063 ns - -
IsWhiteSpace_Old False 260.63 ns 0.291 ns 0.243 ns - -
IsWhiteSpace_New False 160.01 ns 0.259 ns 0.243 ns - -
IsIdentifierStart_Old False 298.28 ns 0.452 ns 0.401 ns - -
IsIdentifierStart_New False 210.78 ns 0.477 ns 0.423 ns - -
IsIdentifierPart_Old False 317.28 ns 0.394 ns 0.349 ns - -
IsIdentifierPart_New False 210.90 ns 0.361 ns 0.301 ns - -
IsHexDigit_Old True 119,770.80 ns 239.219 ns 199.759 ns - -
IsHexDigit_New True 13,125.10 ns 36.490 ns 30.471 ns - -
IsDecimalDigit_Old True 13,130.76 ns 20.747 ns 16.198 ns - -
IsDecimalDigit_New True 13,150.19 ns 56.228 ns 49.844 ns - -
IsWhiteSpace_Old True 180,220.15 ns 349.712 ns 292.025 ns - -
IsWhiteSpace_New True 80,816.84 ns 120.292 ns 106.635 ns - -
IsIdentifierStart_Old True 2,544,295.91 ns 14,167.876 ns 13,252.640 ns 89.8438 1,566,699 B
IsIdentifierStart_New True 83,284.29 ns 285.621 ns 253.196 ns - -
IsIdentifierPart_Old True 3,147,188.09 ns 24,110.925 ns 21,373.707 ns 89.8438 1,566,699 B
IsIdentifierPart_New True 111,228.82 ns 462.914 ns 433.010 ns - -

* use pre-calculated answers for chars
* use HexConverter which has superior check performance
@lahma lahma merged commit 9ccd0bc into sebastienros:main Sep 24, 2022
@lahma lahma deleted the char-improvements branch September 24, 2022 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant