jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
http://javascriptweblog.wordpress.com/2010/11/08/javascripts-dream-team-in-praise-of-split-and-join/ praises the use of .split()
and .join()
for just about anything in JavaScript.
This test case compares their split
/join
-based replaceAll
method with a simple .replace()
using the g
modifier.
The article had this to say about replaceAll
:
It performs almost as well as the native function (the trade off is two extra function calls against a regex match).
Let’s put it to the test!
Ready to run.
Test | Ops/sec | |
---|---|---|
.split('foo').join('bar') replace |
| ready |
.replace(/foo/g, 'bar') |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.