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
<script>
var JS = 'function fibonacci(n) {\
if (n < 2) {\
return 1;\
} else {\
return fibonacci(n-2) + fibonacci(n-1);\
}\
}';
setTimeout(function() {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
var text = JS.replace(/fibonacci/g, 'fibonacciScript');
try {
script.appendChild(document.createTextNode(text));
} catch(e) {
// for IE
script.text = text;
}
head.appendChild(script);
eval(JS.replace(/fibonacci/g, 'fibonacciEval'));
window.fibonacciEval = fibonacciEval;
window.eval(JS.replace(/fibonacci/g, 'fibonacciIndirectEval'));
window.fibonacciIndirectEval || (window.fibonacciIndirectEval = fibonacciIndirectEval);
}, 10);
// define after benchmarks have been added
setTimeout(function() {
// Function One test
ui.benchmarks[2].setup = function() {
var fibonacciFn1 = Function('n','\
if (n < 2) {\
return 1;\
} else {\
var fibonacciFn1 = arguments.callee;\
return fibonacciFn1(n-2) + fibonacciFn1(n-1);\
}\
');
};
// Function Two test
ui.benchmarks[3].setup = function() {
var fibonacciFn2 = Function(JS.replace(/fibonacci/g,
'fibonacciFn2') + 'return fibonacciFn2')();
};
// Normal test
ui.benchmarks[4].setup = function() {
function fibonacci(n) {
if (n < 2) {
return 1;
} else {
return fibonacci(n-2) + fibonacci(n-1);
}
}
};
}, 10);
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
eval |
| ready |
Script |
| ready |
Function One |
| ready |
Function Two |
| ready |
Normal |
| ready |
Indirect eval |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.