Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Firefox 115
Windows 8.1
Desktop
one year ago
Benchmark.js
cartesian from https://stackoverflow.com/a/43053803
1009.1M/s
native .reduce() with map, spread
2.6M/s
native .reduce() with flatmap, concat
1.6M/s
npm:fast-cartesian
1K/s
View exact numbers
Test name Executions per second
cartesian from https://stackoverflow.com/a/43053803 1,009,096,512 Ops/sec
native .reduce() with map, spread 2,631,698 Ops/sec
native .reduce() with flatmap, concat 1,603,978 Ops/sec
npm:fast-cartesian 1,118 Ops/sec
Script Preparation code:
Tests: