Table lookups - this is pretty definitive

Ivan Kazmenko gassa at mail.ru
Tue Apr 1 14:34:27 PDT 2014


On Tuesday, 1 April 2014 at 18:35:50 UTC, Walter Bright wrote:
> Try this benchmark comparing various classification schemes:
> ---------------------------------

10_000 iterations:
Milliseconds 7 10 2
Milliseconds 5 5 1
Milliseconds 8 10 2

100_000 iterations:
Milliseconds 78 93 21
Milliseconds 78 94 21
Milliseconds 78 92 21

1_000_000 iterations:
Milliseconds 584 614 146
Milliseconds 541 612 147
Milliseconds 502 609 146
Milliseconds 529 613 147
Milliseconds 539 606 147

This is DMD 32-bit 2.065.0 on an Intel Core-i7.
The options are -O -release -inline -noboundscheck.

A bit of comments:

1. The benchmark seems rather artificial to me.  The natural 
order of input is fixed, which is nice for both the branch 
predictor (long streaks of each branch) and the array access 
(sequential).

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.)

Ivan Kazmenko.


More information about the Digitalmars-d mailing list