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
Compare the time taken to copy large Typed arrays from the main thread to a WebWorker and back.
Note: Only browsers which support StructureCloning will be able to copy Typed arrays.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="javascript/worker" id="workerFunc">
self.onmessage = function(e) {
postMessage(e.data); // Pass through
};
</script>
<script type="text/javascript">
$(function() {
console.log("Creating data arrays");
var data32mb = new Uint8Array(1024 * 1024 * 32);
var data1mb = new Uint8Array(1024 * 1024);
for (var i=0; i<data32mb.length; i++) {
data32mb[i] = parseInt(Math.random()* 256);
if (data1mb.length > i) {
data1mb[i] = data32mb[i];
}
}
window.data32mb = data32mb;
window.data1mb = data1mb;
console.log("Creating web worker");
window.URL = window.URL || window.webkitURL || null;
var script = document.querySelector('#workerFunc');
var blob = new Blob([script.textContent]);
window.testWorker = new Worker(window.URL.createObjectURL(blob));
console.log("Setup complete");
});
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
32MB |
| ready |
1MB |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.