assemblyscript icon indicating copy to clipboard operation
assemblyscript copied to clipboard

Speedup String#{ indexOf, lastIndexOf }

Open MaxGraey opened this issue 2 years ago • 0 comments

This speedup indexOf matching, especially for long strings and single character.

Benchmark results:

Old
 - SAMPLE22_0:ok:  69.700 ms
 - SAMPLE22_0:eof: 49.000 ms
 - SAMPLE63_1:ok:  90.700 ms
 - SAMPLE63_1:eof: 87.200 ms
 - SAMPLE1k_h:ok:  345.100 ms
 - SAMPLE1k_h:eof: 723.800 ms

New
 - SAMPLE22_0:ok:  40.600 ms  (~1.7x)
 - SAMPLE22_0:eof: 39.400 ms  (~1.3x)
 - SAMPLE63_1:ok:  64.900 ms  (~1.4x)
 - SAMPLE63_1:eof: 54.900 ms  (~1.6x)
 - SAMPLE1k_h:ok:  318.900 ms (~1.0x)
 - SAMPLE1k_h:eof: 350.800 ms (~2.0x)

Benchmark Playground: https://tinyurl.com/pjftv9pp

  • [x] I've read the contributing guidelines
  • [x] I've added my name and email to the NOTICE file

MaxGraey avatar Feb 13 '23 19:02 MaxGraey