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 map1 = {
delegate: {},
put: function(key, val) {
this.delegate[key] = val;
},
get: function(key) {
return this.delegate[key];
},
remove: function(key) {
delete this.delegate[key];
},
contains: function(key) {
return this.delegate[key] !== undefined;
}
};
var map2 = {
delegate: {},
put: function(key, val) {
this.delegate[key] = val;
},
get: function(key) {
if (Object.prototype.hasOwnProperty.call(this.delegate, key)) {
return this.delegate[key];
}
return undefined;
},
remove: function(key) {
delete this.delegate[key];
},
contains: function(key) {
return this.delegate[key] !== undefined;
}
};
var map3 = {
put: function(key, val) {
this[':'+key] = val;
},
get: function(key) {
return this[':'+key];
}
};
var keys = [];
var keys2 = [];
for (var i = 0; i < 100; i++) {
keys.push('HERE_IS_A_LONG_KEY' + i);
keys2.push('HERE_IS_A_DIFFERENT_KEY' + i);
}
for (var k = 0; k < keys.length; k++) {
map1.put(keys[k], k);
map2.put(keys[k], k);
map3.put(keys[k], k);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Delegating, no hasOwnProperty check (all in map) |
| ready |
Delegating, hasOwnProperty check (all in map) |
| ready |
Concat map (all in map) |
| ready |
Delegating, no hasOwnProperty check (none in map) |
| ready |
Delegating, hasOwnProperty check (none in map) |
| ready |
Concat map (none in map) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.