ColinEberhardt / assemblyscript-regex

A regex engine for AssemblyScript
MIT License
86 stars 12 forks source link

Minor tweaks with reserve dynamic arrays #34

Closed MaxGraey closed 3 years ago

ColinEberhardt commented 3 years ago

Thanks @MaxGraey - although the performance improvement is negligible.

Before:

baseline x 235,014 ops/sec ±1.00% (88 runs sampled)
character class x 68,753 ops/sec ±1.02% (87 runs sampled)
concatenation x 19,269 ops/sec ±3.58% (85 runs sampled)
quantifiers x 36,357 ops/sec ±0.92% (87 runs sampled)
range quantifiers x 11,726 ops/sec ±0.61% (88 runs sampled)
alternation x 35,789 ops/sec ±1.35% (91 runs sampled)
multiple regex matches x 3,477 ops/sec ±0.82% (89 runs sampled)

After:

baseline x 236,698 ops/sec ±0.48% (92 runs sampled)
character class x 69,763 ops/sec ±0.45% (93 runs sampled)
concatenation x 20,437 ops/sec ±0.33% (93 runs sampled)
quantifiers x 34,440 ops/sec ±0.43% (94 runs sampled)
range quantifiers x 11,933 ops/sec ±0.39% (89 runs sampled)
alternation x 36,984 ops/sec ±0.35% (92 runs sampled)
multiple regex matches x 3,506 ops/sec ±1.01% (92 runs sampled)
MaxGraey commented 3 years ago

Thanks @MaxGraey - although the performance improvement is negligible.

Yes, but it could be meaningful for large data. All regexps in benchmark relatively small and simple. Will be great add something like this: https://emailregex.com

ColinEberhardt commented 3 years ago

I've tried with a longer regex from the test suite - ^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$ - however it still doesn't make enough difference to feel like a worthwhile optimisation:

before: complex regex matches x 20,420 ops/sec ±0.71% (88 runs sampled) after: complex regex matches x 20,544 ops/sec ±0.33% (94 runs sampled)

MaxGraey commented 3 years ago

ok. Thanks for tests. Closing this due to too negligible improvement

ColinEberhardt commented 3 years ago

Thanks for tests. Closing this due to too negligible improvement

no worries - worth a try!