Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
sort vs reverse test 2
(version: 1)
Comparing performance of:
reverse vs sort
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
var array = Array.from({ length: 10000 }, () => Math.floor(Math.random() * 10000))
Script Preparation code:
var array = Array.from({ length: 10000 }, () => Math.floor(Math.random() * 10000))
Tests:
reverse
array.forEach(n => { const repeat = Math.sqrt(n); const result = [[], []]; for (let i = 1; i <= repeat; i++) { if(n % i === 0) { result.push(i); if (i !== repeat) result.push(n / i); } } result.sort().reverse()[0]; } )
sort
array.forEach(n => { const repeat = Math.sqrt(n); const result = [[], []]; for (let i = 1; i <= repeat; i++) { if(n % i === 0) { result.push(i); if (i !== repeat) result.push(n / i); } } result.sort()[result.length-1]; } )
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
reverse
sort
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/130.0.0.0 Safari/537.36
Browser/OS:
Chrome 130 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
reverse
30.1 Ops/sec
sort
30.3 Ops/sec
Related benchmarks:
Find Smallest Number Not In An Array
Array.sort vs Array.map
Array.sort vs Array.map x2
Array.sort vs Array.map x1
Array.sort 1 vs Array.map x1
sort vs reverse
reverse vs sort
reversed versus ordered (+ cached)
ordered versus reversed (+ cached)
Comments
Confirm delete:
Do you really want to delete benchmark?