Function vs Imperactive object map

Benchmark created on


Setup

let values={}
for (let i=0;i<10_000;i++) {
	values[`V${i}`] = i;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Imperative mapping
  
let res = {};           
for (const k in values) {     
res[k] = `W${values[k]}`
}                                   
                                  
ready
Functional Mapping
Object.fromEntries(
    Object.entries(values).map(([key, value]) => [key, `W${value}`]))
 
ready

Revisions

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