sparse array or map

Benchmark created on


Setup

let list = []
list[36] = {"k": "v"}
list[56] = {"k": "v"}
list[66] = {"k": "v"}

let listMap = new Map()
listMap.set(36, {"k": "v"})
listMap.set(56, {"k": "v"})
listMap.set(66, {"k": "v"})

Test runner

Ready to run.

Testing in
TestOps/sec
sparser
for(let i = 0; i < list.length; i++){
	if(list[i] && list[i].k)
		list[i].k = "v1"
}
ready
map
listMap.forEach((element) => {
	if(element.k)
		element.k = "v1"
})
ready

Revisions

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