Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
sort vs reverse 2
(version: 0)
Comparing performance of:
sort vs reverse
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = Array.from({ length: 10000 }, () => Math.floor(Math.random() * 10000))
Tests:
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((a, b) => a - b) }
reverse
array.forEach(n => { const repeat = Math.sqrt(n); const result = [[], []]; for (let i = 1; i < repeat; i++) { if(n % i === 0) { result[0].push(i); result[1].push(n / i); } } if (Number.isInteger(repeat)) result[0].push(repeat) result[1].reverse(); result.flat() }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
sort
reverse
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?