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 obj = {'test1': {'value': 1},
'test2': {'value': 2},
'test3': {'value': 3},
'test4': {'value': 4},
'test5': {'value': 5},
'test6': {'value': 6},
'test7': {'value': 7},
'test8': {'value': 8},
'test9': {'value': 9},
'test10': {'value': 10},
};
var arr = [{'name': 'test1', 'value': 1},
{'name': 'test2', 'value': 2},
{'name': 'test3', 'value': 3},
{'name': 'test4', 'value': 4},
{'name': 'test5', 'value': 5},
{'name': 'test6', 'value': 6},
{'name': 'test7', 'value': 7},
{'name': 'test8', 'value': 8},
{'name': 'test9', 'value': 9},
{'name': 'test10', 'value': 10}
];
function searchInArray(search){
for(var i=0; i<arr.length; i++){
var val = arr[i];
if(val.name==search){
return val.value;
}
}
}
function searchInObject(search){
var res = obj[search];
if(res){
return res.value;
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Object (exists last) |
| ready |
Array (exists last) |
| ready |
Object (exists first) |
| ready |
Array (exists first) |
| ready |
Object (doesn't exist) |
| ready |
Array (doesn't exist) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.