Test lazy obj access

Benchmark created on


Setup

let obj = Object.fromEntries( Array.from({length: 1000}, e => [String.fromCharCode(e), e] ) );

let obj2 = {};

for(let key in obj)
   obj2[key] = {jsobj: obj[key]}
   

function getMember(o, name) {
	
	let val = o[name]
	if(val !== undefined && val.jsobj === obj[name])
	    return val
	    
     throw new Error('unimplemented !')
}

Test runner

Ready to run.

Testing in
TestOps/sec
Direct Access
for(let key in obj)

     obj[key]
ready
Lazy access
for(let key in obj2)
     getMember(obj2, key)
ready
Lazy access 2
for(let key in obj)
     getMember(obj2, key)
ready

Revisions

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