Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
set vs array mod
(version: 1)
Comparing performance of:
array.push vs set.add vs array.shift vs set.delete
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const b = [] for (let i = 0; i < 3000; i++) b.push(i) const c = new Set(b);
Tests:
array.push
const a = [] for (let i = 0; i < 3000; i++) a.push(i)
set.add
const s = new Set() for (let i = 0; i < 3000; i++) s.add(i)
array.shift
for (let i = 0; i < 3000; i++) b.shift()
set.delete
for (let i = 0; i < 3000; i++) c.delete(i)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
array.push
set.add
array.shift
set.delete
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0
Browser/OS:
Firefox 137 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array.push
288902.6 Ops/sec
set.add
15536.0 Ops/sec
array.shift
146822.1 Ops/sec
set.delete
72129.0 Ops/sec
Related benchmarks:
set.add vs array.push
TestArrayAllocationv2
Array vs Set 2384
test array and set
Array.from vs Array.fill (zeroes)
Set replace
Set from array vs .add
set vs array iteration for,for-of and values v3
set vs array iterationgfgdhahtfdgcvfgshjrhdgfd
Comments
Confirm delete:
Do you really want to delete benchmark?