Table lookups - this is pretty definitive

Ivan Kazmenko gassa at mail.ru
Tue Apr 1 14:52:59 PDT 2014


On Tuesday, 1 April 2014 at 21:34:29 UTC, Ivan Kazmenko wrote:
> On Tuesday, 1 April 2014 at 18:35:50 UTC, Walter Bright wrote:

> 2. The latter function wins, no wonder though, since there's no 
> branching.  (I tried to augment it by actually using the cache 
> in between, but it still wins against my attempts so far.)

The "it" being augmented is the benchmark, the "it" winning being 
the function isIdentifierChar2.

This modification of the benchmark pretends to use a 
stack-allocated array alongside calling the funcions of interest:

http://dpaste.dzfl.pl/1ed247445308

The timings are:
Milliseconds 623 590 229
Milliseconds 629 592 231
Milliseconds 619 596 233
Milliseconds 524 592 283

Funnily, on DPaste, the picture changes:
Milliseconds 1864 1349 1303

Perhaps there is no "-O -release -inline -noboundscheck" tuning 
there.

Ivan Kazmenko.


More information about the Digitalmars-d mailing list