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 createWatch1(last) {
var field = 'a' + Math.floor(Math.random()*999).toString(16);
var obj = {};
obj[field] = 1;
return (last.next = {
obj: obj,
lastValue: 1,
field: field,
next: null
});
}
function createWatch2(last) {
var field = 'a' + Math.floor(Math.random()*999).toString(16);
var obj = {};
obj[field] = 1;
return (last.next = {
obj0: obj, lastValue0: 1, field0: field,
obj1: obj, lastValue1: 1, field1: field,
obj2: obj, lastValue2: 1, field2: field,
obj3: obj, lastValue3: 1, field3: field,
obj4: obj, lastValue4: 1, field4: field,
obj5: obj, lastValue5: 1, field5: field,
obj6: obj, lastValue6: 1, field6: field,
obj7: obj, lastValue7: 1, field7: field,
obj8: obj, lastValue8: 1, field8: field,
obj9: obj, lastValue9: 1, field9: field,
next: null
});
}
var head1 = createWatch1({});
var current = head1;
for(var i = 1; i < 10000; i++) {
current = createWatch1(current);
}
var head2 = createWatch2({});
var current = head2;
for(var i = 1; i < 1000; i++) {
current = createWatch2(current);
}
dirtyCheck1 = function() {
var current = head1;
while(current) {
if (current.obj[current.field] !== current.lastValue) {
throw "Should not get here";
}
current = current.next;
}
};
dirtyCheck2 = function() {
var c = head2;
while(c) {
if (c.obj0[c.field0] !== c.lastValue0) throw "X";
if (c.obj1[c.field1] !== c.lastValue1) throw "X";
if (c.obj2[c.field2] !== c.lastValue2) throw "X";
if (c.obj3[c.field3] !== c.lastValue3) throw "X";
if (c.obj4[c.field4] !== c.lastValue4) throw "X";
if (c.obj5[c.field5] !== c.lastValue5) throw "X";
if (c.obj6[c.field6] !== c.lastValue6) throw "X";
if (c.obj7[c.field7] !== c.lastValue7) throw "X";
if (c.obj8[c.field8] !== c.lastValue8) throw "X";
if (c.obj9[c.field9] !== c.lastValue9) throw "X";
c = c.next;
}
};
///////////////////////////////////////
var size = 10000;
var objs = new Array(size);
var objFields = new Array(size);
var lastValues = new Array(size);
for(var i = 0; i < size; i++) {
var obj = {};
objFields[i] = 'a' + Math.floor(Math.random()*999).toString(16);
lastValues[i] = obj[objFields[i]] = 1;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
dirtyCheck1 |
| ready |
dirtyCheck2 |
| ready |
dirtyCheck3 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.