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
Manual array lookups vs. holey arrays.
//Using an object constructor will make the calculations go faster in chromes v8 engine
function userConstructor (id, name1) {
this.id = id;
this.name1 = name1;
}
//Cached to speed up the object constructor as we are testing lookup speed not the constructor speed.
var name1 = 'Some Random Name';
var a1 = [new userConstructor(29938, name1),
new userConstructor(32994, name1),
new userConstructor(54235, name1),
new userConstructor(43412, name1),
new userConstructor(21346, name1)
];
var a2 = [];
a2[29938] = new userConstructor(29938, name1);
a2[32994] = new userConstructor(32994, name1);
a2[54235] = new userConstructor(54235, name1);
a2[43412] = new userConstructor(43412, name1);
a2[21346] = new userConstructor(21346, name1);
var o = {};
o['29938'] = new userConstructor(29938, name1);
o['32994'] = new userConstructor(32994, name1);
o['54235'] = new userConstructor(54235, name1);
o['43412'] = new userConstructor(43412, name1);
o['21346'] = new userConstructor(21346, name1);
Ready to run.
Test | Ops/sec | |
---|---|---|
Manual Array Lookup |
| ready |
Holey Array by Index |
| ready |
Object by Key |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.