Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
test sort uniq
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
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:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
slow
3.1 Ops/sec
new
28.9 Ops/sec
new2
116.1 Ops/sec
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, ), )