Hacker News new | ask | show | jobs
by tylerhou 374 days ago
Thanks for reminding me, I meant to also benchmark the interchanged version. I updated the file above with the new benchmark results.

The original commenter called `find()` once per vowel, so that's why I benchmarked the regex against the less-idiomatic code.

The interchanged version (loop over haystack outside, over vowels inside) is (mildly) faster than all the regex versions except for short strings & no vowels.

One thing to note is that all the loop versions are not easily generalizable to non-ASCII strings, while the regex version is fairly easily.

1 comments

I poked that loop in compiler explorer for few minutes and I think its allergic to autovectorization. Lets assume that properly vectorized regexp from proper language in the future wins :)