On Tuesday, 31 May 2016 at 19:29:25 UTC, Chris wrote:
Would it speed things up even more, if we put the function `computeSkip` into the loop or is this done automatically by the compiler?

LDC inlines it. DMD does not.

More numbers:

./benchmark.ldc
Search in Alice in Wonderland
       std: 147 ±1
    manual: 100 ±0
      qznc: 121 ±1
     Chris: 103 ±1
    Andrei: 144 ±1
   Andrei2: 105 ±1
Search in random short strings
       std: 125 ±15
    manual: 117 ±10
      qznc: 104 ±6
     Chris: 123 ±14
    Andrei: 104 ±5
   Andrei2: 103 ±4
Mismatch in random long strings
       std: 140 ±22
    manual: 164 ±64
      qznc: 115 ±13
     Chris: 167 ±63
    Andrei: 161 ±68
   Andrei2: 106 ±9
Search random haystack with random needle
       std: 138 ±27
    manual: 135 ±33
      qznc: 116 ±16
     Chris: 141 ±36
    Andrei: 131 ±33
   Andrei2: 109 ±12
 (avg slowdown vs fastest; absolute deviation)
CPU ID: GenuineIntel Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz

Random short strings has haystacks of 10 to 300 characters and needles of 2 to 10. Basically, no time for initialisation.

Random long strings has haystacks of size 1000, 10_000, 100_000, or 1_000_000 and needles 50 to 500. It inserts a character into a random index of the needle to force a mismatch.

The last one is the configuration as before.

Overall, Andrei2 (the lazy compute skip) is really impressive. :)

Reply via email to