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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Browser:
Chrome 127
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Math.max
6487.4 Ops/sec
Reduce
1053.4 Ops/sec
Apply
49137.6 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);