Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Math.min vs Array.sort[0] vs loop
(version: 1)
Test whether Math.min or Array.sort[0] is faster for large number arrays
Comparing performance of:
Math.min vs Array.sort[0] vs Loop
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var massiveArray = new Array(100000).fill().map(e => Math.random()) var n;
Tests:
Math.min
n=Math.min(...massiveArray)
Array.sort[0]
n=massiveArray.sort()[0]
Loop
n=massiveArray[0];for(let i=0;i<massiveArray.length;i++){let v=massiveArray[i];if(v<n)n=v};
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Math.min
Array.sort[0]
Loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.4 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Math.min
4496.2 Ops/sec
Array.sort[0]
65.5 Ops/sec
Loop
10390.7 Ops/sec
Related benchmarks:
array vs int32array with conversion
array vs int32array without conversion
array vs float32array without conversion
array vs float32array withoutconversion
array vs float32array without conversion 2
Array sort & map vs. map & sort
Math.min vs Array.sort[0]
array vs float32array performance test
array vs float32array performance test2
Comments
Confirm delete:
Do you really want to delete benchmark?