Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
1 Math.min() + 1 Math.max() vs 1 Array.reduce()
Compare speed of executing Math.min() and Math.max() for one array vs Array.reduce().
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36
Browser:
Chrome 150
Operating system:
Linux
Device Platform:
Desktop
Date tested:
21 days ago
Reduce
73K/s
Math.min() and Math.max()
28K/s
View exact numbers
Test name
Executions per second
✓
Reduce
72,902 Ops/sec
Math.min() and Math.max()
28,137 Ops/sec
Script Preparation code:
var values = new Array(10000); for (let i = 0; i < values.length; ++i) { values[i] = i % 20; }
Tests:
Math.min() and Math.max()
const min = Math.min(...values); const max = Math.max(...values); return {min, max}
Reduce
return values.reduce( (acc, value ) => { if (acc.min > value) acc.min = value if (acc.max < value) acc.max = value return acc }, { min: Infinity, max: 0 } )