Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Two objects Sort with compare
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/138.0.0.0 Safari/537.36
Browser:
Chrome 138
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
compare
3323.6 Ops/sec
sort
2829.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const compare = (arr) => { return new Date(arr[0].d).getTime() < new Date(arr[1].d).getTime() ? { first: arr[0], second: arr[1] } : { first: arr[1], second: arr[0] }; }; const sort = (arr) => { const sorted = arr.sort( (a, b) => new Date(a.d).getTime() - new Date(b.d).getTime() ); return { first: sorted[0], second: sorted[1] }; }; const generateRandomDate = (start, end) => { return new Date( start.getTime() + Math.random() * (end.getTime() - start.getTime()) ); }; const mockData = Array.from({ length: 1000 }, () => [ { d: generateRandomDate(new Date(2020, 0, 1), new Date()).toISOString(), v: Math.floor(Math.random() * 1000), }, { d: generateRandomDate(new Date(2020, 0, 1), new Date()).toISOString(), v: Math.floor(Math.random() * 1000), }, ]);
Tests:
compare
const compareResult = mockData.map(i => compare(i));
sort
const sortResult = mockData.map(i => sort(i));