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
Vanilla addEventListener vs WeakMap-based event listener
<button id="target"></button>
/* esm.sh - wmel@0.1.1/mod */
var t=new WeakMap,a="\0",listen=function(i,n,o){a.includes(`\0${n}\0`)||(addEventListener(n,s=>t.get(s.target)?.[n]?.forEach?.(r=>r?.(s)),{passive:!0}),a+=n+"\0");let e=t.get(i);e||t.set(i,e={});let d=(e[n]||=[]).push(o)-1;return function(){e[n][d]=void 0}};
//# sourceMappingURL=mod.mjs.map
const test_1_addEventListener = Document.prototype.addEventListener.bind(
document.querySelector("#target"),
"click",
({ target }) => console.log("clicked: ", target)
);
const test_2_WMEL = listen.bind(
null,
document.querySelector("#target"),
"click",
({ target }) => console.log("clicked: ", target)
)
Ready to run.
Test | Ops/sec | |
---|---|---|
addEventListener |
| ready |
WMEL |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.