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
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL || window.oURL;
function parallel(t, count) {
count = count || 4;
var threads = [];
var step = Math.ceil(t / count);
var sum = 0;
var code = 'function calc(from, to){var sum = 0; for(var i = from; i<= to; i++) sum += i;return sum;} onmessage = function(e) {postMessage(calc(e.data.from, e.data.to));close();}';
var bb = new Blob([code], {
type: 'text/javascript'
});
var bbURL = URL.createObjectURL(bb);
for (var from = 1, to = step; from <= t; from += step, to += step) {
var worker = new Worker(bbURL);
worker.onmessage = function(e) {
sum += e.data;
if (--count === 0) {
threads = null;
URL.revokeObjectURL(bbURL);
deferred.resolve();
}
};
worker.postMessage({
from: from,
to: (to > t ? t : to)
});
//console.log({from: from, to: (to > t? t: to)});
threads.push(worker);
}
}
function single(t) {
var sum = 0;
for (var i = 1; i <= t; i++)
sum += i;
return sum;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Single thread |
| ready |
1 thread (Worker) |
| ready |
2 threads |
| ready |
4 threads |
| ready |
8 threads |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.