map to list list

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
 const id = 7
 if (instToObj.has(id)) {
 	let objectId = instToObj.get(id);
    return objList[objectId].i[id];
}
ready
not has
const id = 7
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.