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
let count = 150;
let blackhole = 0;
function range_iter(count) {
return {
[Symbol.iterator]() {
return {
i: 0,
next() {
if(this.i >= count) {
return {done: true};
}
return {done: false, value: this.i++};
}
}
}
}
}
class RangeIter {
constructor(count) {
this.count = count;
}
[Symbol.iterator]() {
this.i = 0;
return this;
}
next() {
if(this.i >= this.count) {
return {done: true};
}
return {done: false, value: this.i++};
}
}
function range_gen(count) {
return {
*[Symbol.iterator]() {
for(let i = 0; i < count; ++i) {
yield i;
}
}
}
}
class RangeGen {
constructor(count) {
this.count = count;
}
*[Symbol.iterator]() {
for(let i = 0; i < this.count; ++i) {
yield i;
}
}
}
function range_keys(count) {
return Array(count).keys();
}
class RangeKeys {
constructor(count) {
this.count = count;
}
*[Symbol.iterator]() {
return Array(this.count).keys();
}
}
function range_arr(count) {
let array = new Array(count);
for(let i = 0; i < count; ++i) {
array[i] = i;
}
return array;
}
function range_call(count, fun) {
for(let i = 0; i < count; ++i) {
fun(i);
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
range (function iteration) |
| ready |
range (class iteration) |
| ready |
range (function generator) |
| ready |
range (class generator) |
| ready |
range (from array keys) (function) |
| ready |
range (from array keys) (class) |
| ready |
range (from range array) |
| ready |
loop |
| ready |
range (callback) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.