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
Comparing the run times of web workers when passing a JSON object vs passing a string that must be parsed in order to be worked with, and now also compared to using transferable object.
var parseCode = "self.onmessage = function (e){var s = e.data.string; self.postMessage(s); };";
var passCode = "self.onmessage = function (e) { var parts = e.data.split(','); self.postMessage(parts[0]); }";
var transferCode = "self.onmessage = function (e) { self.postMessage(e.data, [e.data]); }";
var parseBlob = new Blob([parseCode], {
type: 'text/javascript'
});
var passBlob = new Blob([passCode], {
type: 'text/javascript'
});
var transferBlob = new Blob([transferCode], {
type: 'text/javascript'
});
var aWorker = new Worker(window.URL.createObjectURL(parseBlob));
var bWorker = new Worker(window.URL.createObjectURL(passBlob));
var cWorker = new Worker(window.URL.createObjectURL(transferBlob));
// warm up the transfer based worker
var transferObject = new ArrayBuffer(32);
cWorker.postMessage(transferObject, [transferObject]);
aWorker.terminate();
bWorker.terminate();
cWorker.terminate();
Ready to run.
Test | Ops/sec | |
---|---|---|
Pass JSON |
| ready |
Pass String |
| ready |
Transfer Object |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.