Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array vs Linked List vs Set
compare performance of Array vs Linked List.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser:
Firefox 146
Operating system:
Linux
Device Platform:
Desktop
Date tested:
4 months ago
Test name
Executions per second
Linked List
36438.3 Ops/sec
Array
83677.3 Ops/sec
Set
5431.2 Ops/sec
Script Preparation code:
function createNode(data, next) { return { data: data, next }; } class LinkedList { _head = null; unshift(data) { const node = createNode(data); if (this._head === null) { this._head = node; } else { node.next = this._head; this._head = node; } } shift() { const node = this._head; this._head = this._head.next; return node; } }
Tests:
Linked List
const list = new LinkedList(); let x = 10000; while(x--) { list.unshift(x); }
Array
const array = []; let x = 10000; while(x--) { array.push(x); }
Set
const s = new Set(); let x = 10000; while(x--) { s.add(x); }