var objects = [];
var symbols = [];
var symbolObj = {__proto__: null};
var symbolMap = new Map();
var symbolSet = new Set();
var objectMap = new Map();
var objectSet = new Set();
var emptyObj = {__proto__: null};
var emptyMap = new Map();
var emptySet = new Set();
for (let i = 0; i < 1000; i++) {
objects[i] = {i, sym: Symbol(i)};
symbols[i] = objects[i].sym;
symbolObj[symbols[i]] = i;
symbolSet.add(symbols[i]);
symbolMap.set(symbols[i], i);
objectSet.add(objects[i]);
objectMap.set(objects[i], i);
}
function objRead(obj, keys) {
let total = 0;
for (const key of keys) {
total += obj[key];
}
return total;
}
function objWrite(obj, keys) {
for (const key of keys) {
obj[key] = true;
}
}
function mapRead(map, keys) {
let total = 0;
for (const key of keys) {
total += map.get(key);
}
return total;
}
function mapWrite(map, keys) {
for (const key of keys) {
map.set(key, true);
}
}
function setRead(set, keys) {
let total = 0;
for (const key of keys) {
total += set.has(key) ? 1 : 0;
}
return total;
}
function setWrite(set, keys) {
for (const key of keys) {
set.add(key);
}
}
objRead(symbolObj, symbols)
setRead(symbolSet, symbols)
mapRead(symbolMap, symbols)
setRead(objectSet, objects)
mapRead(objectMap, objects)
objWrite(symbolObj, symbols)
setWrite(symbolSet, symbols)
mapWrite(symbolMap, symbols);
setWrite(objectSet, objects);
mapWrite(objectMap, objects);
objWrite(emptyObj, symbols);
setWrite(emptySet, symbols);
mapWrite(emptyMap, symbols);
setWrite(emptySet, objects);
mapWrite(emptyMap, objects);
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Symbol read: Object | |
Symbol read: Set | |
Symbol read: Map | |
Object read: Set | |
Object read: Map | |
Symbol write: Object | |
Symbol write: Set | |
Symbol write: Map | |
Object write: Set | |
Object write: Map | |
Symbol insert: Object | |
Symbol insert: Set | |
Symbol insert: Map | |
Object insert: Set | |
Object insert: Map |
Test name | Executions per second |
---|---|
Symbol read: Object | 74141.2 Ops/sec |
Symbol read: Set | 142846.6 Ops/sec |
Symbol read: Map | 134411.3 Ops/sec |
Object read: Set | 96863.8 Ops/sec |
Object read: Map | 95626.0 Ops/sec |
Symbol write: Object | 68587.5 Ops/sec |
Symbol write: Set | 64844.8 Ops/sec |
Symbol write: Map | 52930.6 Ops/sec |
Object write: Set | 49480.9 Ops/sec |
Object write: Map | 43045.1 Ops/sec |
Symbol insert: Object | 54931.5 Ops/sec |
Symbol insert: Set | 64928.5 Ops/sec |
Symbol insert: Map | 55977.2 Ops/sec |
Object insert: Set | 52553.2 Ops/sec |
Object insert: Map | 44808.8 Ops/sec |
It seems like we have a JSON string of test results from various browsers and devices.
What would you like me to help with? Extract some specific information, perform calculations, or something else?