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
All that a obj.hasOwnProperty() method can return is in Object.keys(obj). Is it faster lookup an index than inspect an object?
var obj = {
"dateAdded": 1386900688175,
"id": "5707",
"index": 0,
"parentId": "127",
"title": "Gmail",
"url": "http://mail.google.com/mail/u/0/#inbox"
};
var folder = {
'children': [0],
'dateAdded': 1387413393280,
'dateGroupModified': 1387418822179,
'id': "782",
'index': 12,
'parentId': "127",
'title': "Folder"
};
var cachedObjKeys = Object.keys(obj),
objKeys;
Ready to run.
Test | Ops/sec | |
---|---|---|
hasOwnProperty |
| ready |
Object.keys + indexOf |
| ready |
cached keys + indexOf |
| ready |
in |
| ready |
Key truthy if |
| ready |
Key truthy if !== |
| ready |
true Key if-else |
| ready |
true Key if-else !== |
| ready |
false key if-else |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.