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
add set
var a = 1;
var b = 2.15923;
var c = 0xFFFFFF | 0;
var d = 'asdf';
var e = 'i should be undefined';
function MapStruct(a, b, c, d) {
this[a] = a;
this[b] = b;
this[c] = c;
this[d] = d;
};
var noproto = Object.create(null);
noproto[a] = a;
noproto[b] = b;
noproto[c] = c;
noproto[d] = d;
var obj = {};
obj[a] = a;
obj[b] = b;
obj[c] = c;
obj[d] = d;
if (typeof Map !== "undefined") {
var map = new Map();
map.set(a, a);
map.set(b, b);
map.set(c, c);
map.set(d, d);
}
if (typeof Set !== "undefined") {
var set = new Set();
set.add(a);
set.add(b);
set.add(c);
set.add(d);
}
var struct = new MapStruct(a, b, c, d);
Ready to run.
Test | Ops/sec | |
---|---|---|
obj property lookup |
| ready |
struct property lookup |
| ready |
map lookup 1 |
| ready |
obj property lookup (safe) |
| ready |
obj property lookup (very safe) |
| ready |
struct property lookup (safe) |
| ready |
struct property lookup (very safe) |
| ready |
obj no prototype property lookup |
| ready |
set |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.