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
var innerUniqueIndex = 0;
function makeInner() {
// Consider different scope by es module import.
var key = '__\0ec_inner_' + innerUniqueIndex++ + '_' + Math.random().toFixed(5);
return function (hostObj) {
return hostObj[key] || (hostObj[key] = {});
};
}
function makeInnerSimpleKey() {
// Consider different scope by es module import.
return function (hostObj) {
return hostObj.nest || (hostObj.nest = {});
};
}
function makeInnerSimpleKey2() {
// Consider different scope by es module import.
return function (hostObj) {
var o = hostObj.nest;
if (o !== undefined) {
return o;
}
return (hostObj.nest = {});
};
}
const inner = makeInner();
const innerSimple = makeInnerSimpleKey();
const innerSimple2 = makeInnerSimpleKey2();
const obj = {
dataIndex: 2
}
const obj2 = {
nest: {
dataIndex: 2
}
};
const obj3 = {}
// inner(obj3).dataIndex = 2;
const obj4 = {}
// innerSimple(obj4).dataIndex = 2;
const obj5 = {}
// innerSimple2(obj5).dataIndex = 2;
var host = [];
function save(obj) {
if (host.length > 1000) {
host = [];
}
host.push(obj);
}
host = [];
Ready to run.
Test | Ops/sec | |
---|---|---|
inner simple 2 |
| ready |
inner simple 2-1 |
| ready |
Not nest |
| ready |
Nest |
| ready |
inner |
| ready |
inner with simple key |
| ready |
inner simple 2-2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.