Skip to content

Avoid array lookups where simple constants are fine #35

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

Merged
merged 2 commits into from
Mar 18, 2013
Merged

Avoid array lookups where simple constants are fine #35

merged 2 commits into from
Mar 18, 2013

Conversation

DmitryOlshansky
Copy link
Contributor

A 15 minute fix that gets a big performance boost (about 20-30%)!

The noise is awfully high though, so I'm looking at sample mode mostly it could bigger or a smaller. What I'm seeing I think is that system call overhead is far higher then the time to lex the thing.

Logs of runs on core i5-3170 at my workplace.
dscanner-meta truly utilizes meta-programming unlike the current version (dscanner-old):

dmitry@dmitry-pc ~/Dscanner $ avgtime -r 450 -q ./dscanner-old --tokenCount ../phobos/std/datetime.d


Total time (ms): 8719.33
Repetitions : 450
Sample mode : 22 (81 ocurrences)
Median time : 20.492
Avg time : 19.3763
Std dev. : 2.97428
Minimum : 13.957
Maximum : 25.352
95% conf.int. : [13.5468, 25.2058] e = 5.82948
99% conf.int. : [11.715, 27.0375] e = 7.66123
EstimatedAvg95%: [19.1015, 19.6511] e = 0.274804
EstimatedAvg99%: [19.0151, 19.7374] e = 0.361154

dmitry@dmitry-pc ~/Dscanner $ avgtime -r 450 -q ./dscanner-meta --tokenCount ../phobos/std/datetime.d


Total time (ms): 8114.66
Repetitions : 450
Sample mode : 15 (117 ocurrences)
Median time : 17.304
Avg time : 18.0326
Std dev. : 2.89978
Minimum : 12.55
Maximum : 23.87
95% conf.int. : [12.3491, 23.716] e = 5.68346
99% conf.int. : [10.5633, 25.5019] e = 7.46933
EstimatedAvg95%: [17.7647, 18.3005] e = 0.267921
EstimatedAvg99%: [17.6805, 18.3847] e = 0.352107
dmitry@dmitry-pc ~/Dscanner $

Hackerpilot added a commit that referenced this pull request Mar 18, 2013
Avoid array lookups where simple constants are fine
@Hackerpilot Hackerpilot merged commit aa406c7 into dlang-community:range-based-lexer Mar 18, 2013
@@ -485,7 +484,7 @@ L_advance:
if (!src.canPeek())
{
current.type = TokenType.dot;
current.value = getTokenValue(TokenType.dot);
current.value = tokenValue!(TokenType.dot);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised the optimizer didn't do this for us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here he most likely did it, but see other cases where current.type is used.
Plus debug builds matter and there is dmd to care about ;)

Vladiwostok pushed a commit to Vladiwostok/D-Scanner-OG that referenced this pull request Dec 12, 2024
* replace libdparse in imports sortedness visitor

* minor refactor
Vladiwostok pushed a commit to Vladiwostok/D-Scanner-OG that referenced this pull request Jan 12, 2025
* replace libdparse in imports sortedness visitor

* minor refactor
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.

2 participants