Hackerpilot/Dscanner — pull request #35 by blackwhale (2013-03-18 11:37:53+00:00)
Title: Avoid array lookups where simple constants are fine

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

The noise is awfully high though, so I'm looking at sample mode mostly it could be 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 $