blob: 380ff8e64fd8824b6607247dfa5075f8594d1a0f [file] [log] [blame]
function assert(b) {
if (!b)
throw new Error("Bad!");
}
noInline(assert);
let weakMap = new WeakMap;
function objectKey(o) {
return weakMap.get(o);
}
noInline(objectKey);
const iters = 1000000;
let start = Date.now();
{
let o = {f: 20};
var array = [];
for (var i = 0; i < 10; i++) {
let newObject = { f: i };
weakMap.set(newObject, i);
array[i] = newObject;
}
for (var j = 0; j < iters; ++j) {
for (let i = 0; i < 10; i++)
assert(objectKey(array[i]) === i);
}
}
const verbose = false;
if (verbose)
print(Date.now() - start);