Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
tickets
(version: 0)
Comparing performance of:
test - alex vs test - kirill
Created:
5 years ago
by:
Guest
Jump to the latest result
Tests:
test - alex
const foo=(tickets)=>tickets.sort((a, b)=>{ if(a.to === b.from) return -1; if(b.to === a.from) return 1; return 0; }); foo([ { from: 'London', to: 'Moscow' }, { from: 'NY', to: 'London' }, { from: 'Moscow', to: 'SPb' }, ]);
test - kirill
function findShortPath(tickets){ const result = []; const mapOfTo = {}; const mapOfFrom = {}; tickets.forEach(ticket => { mapOfTo[ticket['to']] = true; mapOfFrom[ticket['from']] = ticket; }); let start = tickets.find(ticket => !mapOfTo.hasOwnProperty(ticket['from'])).from; let foundTicket while(foundTicket = mapOfFrom[start]){ result.push(foundTicket); start = foundTicket['to']; } return result; } findShortPath([ { from: 'London', to: 'Moscow' }, { from: 'NY', to: 'London' }, { from: 'Moscow', to: 'SPb' }, ]);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
test - alex
test - kirill
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!
Related benchmarks:
sumOfEventNumbers-vanilla-vs-rxjs
sumOfEventNumbers-vanilla-vs-rxjs-7
JS Events Emitting
JS Events Emitting 2
List iteration performance test 1
Comments
Confirm delete:
Do you really want to delete benchmark?