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
function __add__A(a,b){ return a+b }
function * genA(beg, end, step) {
if(false) // >= 32 not supported
throw new Error("Not implemented !")
for(let iter = beg; iter < end; iter+=step)
yield iter;
}
/****************************/
function __add__B(a,b){ return a+b }
function * genB(beg, end, step) {
if(false) // >= 32 not supported
throw new Error("Not implemented !")
for(let iter = beg; iter < end; iter+=step)
yield iter;
}
/****************************/
function __inplace_add__C(a,b){
a[0] += b[0];
return a }
function * genC(beg, end, step) {
if(false) // >= 32 not supported
throw new Error("Not implemented !")
const a = new BigInt64Array(3)
a[0] = beg;
const _end = a[1] = end;
const _step = a[2] = step;
const iter = new BigInt64Array(1)
for( ; a[0] < _end; a[0]+=_step) {
iter[0] = a[0]; // need to copy
yield iter;
}
}
/****************************/
function __inplace_add__D(a,b){
a[0] += b[0];
return a }
function * genD(beg, end, step) {
if(false) // >= 32 not supported
throw new Error("Not implemented !")
const a = new Int32Array(3)
const iter = new Int32Array(1)
a[0] = beg;
const _end = a[1] = end;
const _step = a[2] = step;
for( ; a[0] < _end; a[0]+=_step) {
iter[0] = a[0]; // need to copy
yield iter;
}
}
/****************************/
function __inplace_add__E(a,b){
a[0] += b[0];
return a }
function * genE(beg, end, step) {
if(false) // >= 32 not supported
throw new Error("Not implemented !")
const a = new Float64Array(3)
const iter = new Float64Array(1)
a[0] = beg;
const _end = a[1] = end;
const _step = a[2] = step;
for( ; a[0] < _end; a[0]+=_step) {
iter[0] = a[0]; // need to copy
yield iter;
}
}
/****************************/
function __inplace_add__F(a,b){
a.value[0] += b.value[0];
return a }
function * genF(beg, end, step) {
if(false) // >= 32 not supported
throw new Error("Not implemented !")
const a = [beg, end, step];
let iter = {type: "integer", value:[0]}
let i = a[0]
const _end = a[1] = end;
const _step = a[2] = step;
for( ; i < _end; i += _step ) {
iter.value[0] = i; // need to copy
yield iter;
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Native |
| ready |
BigInt |
| ready |
BigInt64Array |
| ready |
Int32Array |
| ready |
Float64Array |
| ready |
Array struct |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.