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
Just doing some benchmarks.
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.3.0/lodash.min.js"></script>
<script>
var a = [],
newArray = [];
function forLoop(array, fn) {
for (var index = 0, len = array.length; index < len; ++index) {
fn(array[index]);
}
}
function process(i) {
return i * i + i;
}
function iterator(i) {
newArray.push(process(i));
}
function reportArray(name, array) {
console.log('' + name + ': [' + array[0] + '..' + array[array.length-1] + '] (' + a.length + ')');
}
function reportResults() {
reportArray('a', a);
reportArray('newArray', newArray);
}
</script>
a.length = 0;
newArray.length = 0;
for (var i = 1, len = 1000; i <= len; ++i) {
a.push(i);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
for loop |
| ready |
Array.forEach |
| ready |
Array.map |
| ready |
lodash.forEach |
| ready |
lodash.map |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.