Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Math.max() without spread vs reduce vs apply
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Math.max
16023.4 Ops/sec
Reduce
1698.1 Ops/sec
Apply
65571.8 Ops/sec
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((a, b) => Math.max(a, b), -Infinity);
Apply
function getMaxOfArray(numArray) { return Math.max.apply(null, numArray); } return getMaxOfArray(values);