Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array vs Linked List vs Set
(version: 1)
compare performance of Array vs Linked List.
Comparing performance of:
Linked List vs Array vs Set
Created:
10 months ago
by:
Guest
Jump to the latest result
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); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Linked List
Array
Set
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser/OS:
Firefox 146 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Linked List
36438.3 Ops/sec
Array
83677.3 Ops/sec
Set
5431.2 Ops/sec
Related benchmarks:
Switch vs map
undefined vs. typeof vs. in vs. hasOwnProperty vs wrapped function
Different functions
Switch vs new Map
Object vs Map 5.2
Switch vs Map object
Deep equal
Switch vs map test2
Switch vs map first value
Comments
Confirm delete:
Do you really want to delete benchmark?