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; Ubuntu; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0
Browser:
Firefox 140
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
Linked List
5864.1 Ops/sec
Array
46122.8 Ops/sec
Set
3105.4 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); }