4 ms·
The top reply says "Don't underestimate PHP when regexes are involved." and linked a benchmark [1]. But in that benchmark apparently Rust is faster than PHP (T
by fireattack 7y ago
The top reply says "Don't underestimate PHP when regexes are involved." and linked a benchmark [1].
But in that benchmark apparently Rust is faster than PHP (The slowest "Rust #2" is 2.45 sec. while PHP is 2.80 sec. He also mentioned "PCRE", but the ones with Perl in name are even much more slower [the fastest being 14.95 sec.]).
Did I miss his point by linking that benchmark, or did I interpret the benchmark wrong?
[1]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/regexredux.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- detaro 7y agoOne could expect PHP to be a lot slower, the benchmark shows it can keep up. PCRE is the name of the regex library used by (among others) PHP, which is why PHP is good at regex. Other comments address why the Rust program is not optimal.
- o_p 7y agoI guess the poster didnt saw Rust being faster, only that PHP is pretty fast, or at least not slow (so it should be underestimated). Id take that slowdown any day just not having to touch Rust though :^)
- 1_player 7y agoTo be fair, the benchmarks game PHP script does quite more work that just matching a regexp, like forking into multiple interpreters (which can't be that fast) and communicating through a message queue. So any speed difference between Rust's and PCRE/PHP gets lost among the noise.
- igouy 7y ago> … "PCRE", but the ones with Perl in name… fyi "Regular Expressions (Perl-Compatible)" https://www.php.net/manual/en/book.pcre.php https://www.php.net/manual/en/book.pcre.php
- fireattack 7y agoThanks for letting me know.
- liveoneggs 7y agolook at the source code- all of the fastest are using PCRE
- oconnor663 7y agoBeing within a factor of 2 of perfectly optimized C code is excellent performance for a program in any language, including C :) Note that the fastest Java and JS programs are 4x slower than this, and Python and Perl are even slower. That said, I am surprised that Perl does so poorly. It might just be that no one's submitted a perfectly optimized solution for Perl?