map to list list (v5)

Revision 5 of this benchmark created on


Setup

const instToObj = new Map()
instToObj.set(1,3)
instToObj.set(2,3)
instToObj.set(3,1)
instToObj.set(4,2)
instToObj.set(5,2)
instToObj.set(6,1)

const objList = [{'i' : [ , , , 3, , , 6]}, {'i' : [ , , , , 4, 5]}, {'i' : [ , 1,2]},]

Test runner

Ready to run.

Testing in
TestOps/sec
with has 7
 let id = 7
 if (instToObj.has(id)) {
 	let objectId = instToObj.get(id);
    return objList[objectId].i[id];
}
ready
not has 7
let id = 7
let objectId = instToObj.get(id);
if(objectId )
	return objList[objectId].i[id];
ready
with has 5
 let id = 5
 if (instToObj.has(id)) {
 	let objectId = instToObj.get(id);
    return objList[objectId].i[id];
}
ready
not has 5
let id = 5
let objectId = instToObj.get(id);
if(objectId )
	return objList[objectId].i[id]
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.