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
Benchmarking string methods given in airbnb's style guide
//Show that results are equal when JITd
<script>
function a() {
var errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';
}
function b() {
var errorMessage = 'This is a super long error that \
was thrown because of Batman. \
When you stop to think about \
how Batman had anything to do \
with this, you would get nowhere \
fast.';
}
function c() {
var errorMessage = 'This is a super long error that ' +
'was thrown because of Batman.' +
'When you stop to think about ' +
'how Batman had anything to do ' +
'with this, you would get nowhere ' +
'fast.';
}
function d() {
var errorMessage = 'This is a super long error that ' + 'was thrown because of Batman.' + 'When you stop to think about ' + 'how Batman had anything to do ' + 'with this, you would get nowhere ' + 'fast.';
}
function e(){
var errorMessage =
['This is a super long error that was thrown',
'because of Batman. When you stop to think about',
'how Batman had anything to do with this, you',
'would get nowhere fast.'].join(' ');
}
var l = 10000;
while (l--) {
a()
b()
c()
d()
e()
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Long string without breaks |
| ready |
Long string with breaks |
| ready |
Long string with concats |
| ready |
Long string with concats on one line |
| ready |
Long string as an array of strings + join(' ') |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.