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
I was considering if I could use the BroadcastChannel API from inside Workers to get logs back to the main thread UI, since that seemed simpler than wiring up message passing through all classes. So I wanted to see how much worse they fare with lots of small messages.
// create worker with inline script blob
let script = "let bc = new BroadcastChannel('broadcast'); onmessage = ev => { for (let i = 0; i <= ev.data.n; i++) { if (ev.data.broadcast) { bc.postMessage({ i }) } else { postMessage({ i }) }; }; }";
let blob = URL.createObjectURL(new Blob([script]));
let worker = new Worker(blob);
console.log(blob);
// pick a common n for the loops
let n = 10_000;worker.terminate();Ready to run.
| Test | Ops/sec | |
|---|---|---|
| Worker.postMessage | | ready |
| BroadcastChannel.postMessage | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.