Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
test sort uniq2
(version: 0)
Comparing performance of:
slow vs new vs new2 vs nospread vs nodate
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.0/ramda.min.js"></script>
Script Preparation code:
var data = [] function getRandomDate() { const startMillis = new Date('2020-06-02T00:00:00.000Z').getTime(); const endMillis = new Date().getTime(); const randomMillis = startMillis + Math.random() * (endMillis - startMillis); const randomDate = new Date(randomMillis); return randomDate; } for (var i = 0; i < 14000; i++) { data.push({ customerId: `CTM-${i % 10}`, worklistId: `WL-${i % 100}`, createdDateTime: getRandomDate() }); }
Tests:
slow
var result = R.uniqBy( R.props(['worklistId', 'customerId']), [...data].sort( (a, b) => new Date(a.createdDateTime).getTime() - new Date(b.createdDateTime).getTime(), ), )
new
var result = R.uniqWith( (a, b) => a.customerId === b.customerId && a.worklistId === b.worklistId, [...data].sort( (a, b) => new Date(a.createdDateTime).getTime() - new Date(b.createdDateTime).getTime(), ), )
new2
var result = R.uniqWith( (a, b) => a.customerId === b.customerId && a.worklistId === b.worklistId, data.sort( (a, b) => a.createdDateTime - b.createdDateTime, ), )
nospread
var result = R.uniqWith( (a, b) => a.customerId === b.customerId && a.worklistId === b.worklistId, [...data].sort( (a, b) => a.createdDateTime - b.createdDateTime, ), )
nodate
var result = R.uniqWith( (a, b) => a.customerId === b.customerId && a.worklistId === b.worklistId, data.sort( (a, b) => new Date(a.createdDateTime).getTime() - new Date(b.createdDateTime).getTime(), ), )
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
slow
new
new2
nospread
nodate
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser/OS:
Chrome 119 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
slow
2.1 Ops/sec
new
14.0 Ops/sec
new2
85.1 Ops/sec
nospread
139.7 Ops/sec
nodate
70.8 Ops/sec
Related benchmarks:
Date sort
Lodash min vs sort moment (lodash 4.7.11)
Lodash sort vs array.prototype.sort vs. sort by key
test sort uniq
Comments
Confirm delete:
Do you really want to delete benchmark?