On 06-Jul-12 00:16, Roman D. Boiko wrote:
isKeyword_Dummy (baseline): 2738 [microsec] total, 50 [ns / lookup].
This one calculates a sum of all identifier code units. Included for
comparison.

isKeyword_Dictionary: 4247 [microsec] total, 242 [ns / lookup].
Check whether an identifier is a keyword using AA (dictionary) lookup.

isKeyword_SwitchByLengthThenByChar: 1593 [microsec] total, 91 [ns /
lookup].
Switch by identifier length at the top, then recursively switch by each
character. Clearly a winner, but I think it can be improved further.

I'd stress the fact that it's a fully unrolled & hard-coded
switch that takes a lot of pages (~72Kbytes). It's easily be perfect.
Sorry, couldn't resist ;)
And I'm not sure how much it could be optimized maybe some measly 10-30%.

Total: 104183 identifiers + 17488 keywords.
Analyzed the largest Phobos file (DateTime? I didn't check the name.)
Results are consistent for other files, too.
It is std.datetime as I've been running this benchmark against it and seen the same numbers :)

--
Dmitry Olshansky


Reply via email to