Script Preparation code:
AخA
 
var arr10k = Array.from(Array(10000)).map((x, i) => ({ x1: i, x2: i * 2, x4: i * 4 }));
Tests:
  • Map from .reduce

     
    arr10k.reduce((acc, x) => acc.set(x.x1, x), new Map());
  • Map from .map

     
    new Map(arr10k.map(x => [x.x1, x]));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Map from .reduce
    Map from .map

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.115 Safari/537.36
Chrome 92 on Windows
View result in a separate tab
Test name Executions per second
Map from .reduce 894.5 Ops/sec
Map from .map 679.4 Ops/sec