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
A simple performance test to see how object keys compares against finding any object in an array using array.indexOf versus object[key]
var _nextObjectID = 0;
function MyObject() {
this.ID = _nextObjectID;
_nextObjectID++;
}
var _array = [];
var _hash = {};
var obj = null;
for (var i = 0; i < 10000; i++) {
obj = new MyObject();
_array.push(obj);
_hash[obj.ID] = obj;
}
//Randomly select the object we will be looking for
var _objID = Math.round(Math.random() * _nextObjectID);
var _findObject = _array[_objID];
Ready to run.
Test | Ops/sec | |
---|---|---|
array.indexOf(obj) |
| ready |
object[id] |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.