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
array = [];
for (let i = 0; i < 100000; i++) {
array.push(i);
}
function *range(n) { for (let i = 0; i < n; i++) yield i; }
class Range {
constructor(n) {
this.i = 0;
this.n = n;
}
[Symbol.iterator]() { return this; }
next() {
if (this.i < this.n) {
return {value: this.i++, done: false};
} else {
return {value: undefined, done: true};
}
}
}
class Range2 {
constructor(n) {
this.n = n;
this.value = -1;
this.done = false;
}
[Symbol.iterator]() { return this; }
next() {
this.value++;
if (this.value >= this.n) {
this.done = true;
}
return this;
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
For loop |
| ready |
Generator |
| ready |
Iterator |
| ready |
Iterator2 (non-allocating) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.