Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Math.max() spread vs reduce() vs apply()
Compare speed of Math.max() apread, reduce() and apply()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0
Browser:
Firefox 52
Operating system:
Windows XP
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Math.max
1089.5 Ops/sec
Reduce
5688.6 Ops/sec
Apply
22950.0 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);