Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash test sort by 1 vs 2
(version: 1)
Comparing performance of:
sort by 1 vs sort by twice
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
Script Preparation code:
function shuffle(a) { var j, x, i; for (i = a.length; i; i--) { j = Math.floor(Math.random() * i); x = a[i - 1]; a[i - 1] = a[j]; a[j] = x; } } var all = []; var ids = []; var allLength = 1000; var idsLength = 100; for(var i = 0; i < allLength; i++) { all[i] = i; } for(var i = 0; i < allLength; i++) { ids[i] = i; } ids = ids.splice(allLength - idsLength) shuffle(all); shuffle(ids);
Tests:
sort by 1
var output = _.sortBy(ids) console.log(output);
sort by twice
let output = _.sortBy(ids) output = _.sortBy(ids, a => a[5]) console.log(output);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
sort by 1
sort by twice
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/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser/OS:
Chrome 120 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
sort by 1
27124.4 Ops/sec
sort by twice
20639.7 Ops/sec
Related benchmarks:
lodash test
lodash test
lodash test
lodash test
lodash test
lodash test
lodash test
lodash test
lodash shuffle
Comments
Confirm delete:
Do you really want to delete benchmark?