Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Math.max() vs Array.reduce() fork
(version: 1)
Compare speed of Math.max() vs Array.reduce().
Comparing performance of:
Math.max vs Reduce
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var values = new Array(5000); for (let i = 0; i < values.length; ++i) { values[i] = i % 20; }
Tests:
Math.max
return Math.max(...values);
Reduce
return values.reduce((prev, curr) => { if (curr > prev) return curr; return prev; }, values[0]);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Math.max
Reduce
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Math.max
104499.5 Ops/sec
Reduce
30729.3 Ops/sec
Related benchmarks:
Math.max() vs Array.reduce()
Math.max() vs Array.reduce.apply()
Math.min() vs Array.reduce()
Math.max() vs Array.reduce() 4
Math.max() vs Array.reduce() vs for element of array loop
Math.max() vs Array.reduce() xxx
Math.max() vs Array.reduce() xxxyyy
Math.max() vs Array.reduce() vs for of
Math.max.apply() vs Array.reduce()
Comments
Confirm delete:
Do you really want to delete benchmark?