faster splitter

Chris via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 1 02:28:44 PDT 2016


On Tuesday, 31 May 2016 at 21:29:34 UTC, Andrei Alexandrescu 
wrote:
>
> You may want to then try https://dpaste.dzfl.pl/392710b765a9, 
> which generates inline code on all compilers. -- Andrei

I've added it as `Andrei3`. It runs faster with dmd, but it's not 
as good with ldc. Seems like ldc performs some extra optimization 
when moving `computeSkip` into the loop, something it doesn't 
bother to do when it's already there.

dmd -O -release -inline -noboundscheck *.d -ofbenchmark.dmd
./benchmark.dmd
Search in Alice in Wonderland
        std: 190 ±4
     manual: 115 ±4
       qznc: 106 ±2
      Chris: 160 ±4
     Andrei: 159 ±4
    Andrei2: 108 ±2
    Andrei3: 100 ±0
Search in random short strings
        std: 222 ±27
     manual: 193 ±49
       qznc: 120 ±12
      Chris: 224 ±57
     Andrei: 114 ±9
    Andrei2: 106 ±5
    Andrei3: 102 ±3
Mismatch in random long strings
        std: 186 ±28
     manual: 206 ±85
       qznc: 118 ±14
      Chris: 265 ±104
     Andrei: 194 ±85
    Andrei2: 116 ±18
    Andrei3: 102 ±4
Search random haystack with random needle
        std: 189 ±38
     manual: 171 ±45
       qznc: 118 ±11
      Chris: 225 ±52
     Andrei: 149 ±32
    Andrei2: 110 ±7
    Andrei3: 103 ±6
  (avg slowdown vs fastest; absolute deviation)
CPU ID: GenuineIntel Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz

./benchmark.ldc
Search in Alice in Wonderland
        std: 170 ±1
     manual: 143 ±2
       qznc: 133 ±1
      Chris: 144 ±1
     Andrei: 196 ±10
    Andrei2: 100 ±0
    Andrei3: 111 ±1
Search in random short strings
        std: 223 ±30
     manual: 211 ±51
       qznc: 124 ±12
      Chris: 223 ±61
     Andrei: 115 ±10
    Andrei2: 102 ±3
    Andrei3: 105 ±4
Mismatch in random long strings
        std: 181 ±17
     manual: 253 ±109
       qznc: 146 ±24
      Chris: 248 ±108
     Andrei: 228 ±96
    Andrei2: 101 ±2
    Andrei3: 108 ±6
Search random haystack with random needle
        std: 187 ±22
     manual: 208 ±60
       qznc: 152 ±27
      Chris: 202 ±58
     Andrei: 173 ±35
    Andrei2: 102 ±4
    Andrei3: 110 ±8
  (avg slowdown vs fastest; absolute deviation)
CPU ID: GenuineIntel Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz



More information about the Digitalmars-d mailing list