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
Checks the speed of function bind or closure when added as listener
<div id="foo"></div>
class Test {
constructor(div) {
this.div = div;
}
addBindListener() {
this.eventBind = this.testMethod.bind(this);
this.div.addEventListener('test', this.eventBind);
}
addClosureListener() {
this.eventClosure = () => this.testMethod();
this.div.addEventListener('test', this.eventClosure);
}
testMethod() {
this.div.innerHTML = 'Test';
}
destroy() {
if (this.eventBind) {
this.div.removeEventListener('test', this.eventBind);
this.eventBind = null;
}
if (this.eventClosure) {
this.div.removeEventListener('test', this.eventClosure);
this.eventClosure = null;
}
}
}
if (window.test) {
window.test.destroy();
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Bind |
| ready |
Closure |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.