Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
push vs spread in building graph from edges
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
push
4221480.5 Ops/sec
spread
3196669.0 Ops/sec
Tests:
push
const edges = [ ['w', 'x'], ['x', 'y'], ['z', 'y'], ['z', 'v'], ['w', 'v'] ]; const buildGraphPush = (edges) => { let graph = {}; for (let e of edges) { const [a, b] = e; if (!(a in graph)) graph[a] = []; if (!(b in graph)) graph[b] = []; graph[a].push(b); graph[b].push(a); } return graph; }; buildGraphPush(edges);
spread
const edges = [ ['w', 'x'], ['x', 'y'], ['z', 'y'], ['z', 'v'], ['w', 'v'] ]; const buildGraphSpread = (edges) => { let graph = {}; for (let e of edges) { const [a, b] = e; graph[a] = [...(graph[a] || []), b]; graph[b] = [...(graph[b] || []), a]; } return graph; }; buildGraphSpread(edges);