Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
set.add vs array.push Fabien
(version: 0)
Comparing performance of:
conditional array.push vs set.add
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = []; var set = new Set(); var map = new Map(); var existingItem1 = {}; var existingItem2 = {}; var existingItem3 = {}; var newItem1 = {}; var newItem2 = {}; var newItem3 = {}; for (let i = 0, item; i < 100; i++) { item = {index: i}; array.push(item); set.add(item); map.set(item, 0); } array.push(existingItem1, existingItem2, existingItem3); set.add(existingItem1); set.add(existingItem2); set.add(existingItem3); map.set(existingItem1, 0); map.set(existingItem2, 0); map.set(existingItem3, 0);
Tests:
conditional array.push
array.push(existingItem1); array.push(newItem1); array.push(existingItem2); array.push(newItem2); array.push(existingItem3); array.push(newItem3);
set.add
set.add(existingItem1); set.add(newItem1); set.add(existingItem2); set.add(newItem2); set.add(existingItem3); set.add(newItem3);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
conditional array.push
set.add
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
set.add vs array.push vs map.set
set.add vs array.push vs map.set fork42
new Map vs set array to map
set.add vs array.push vs map.set
Comments
Confirm delete:
Do you really want to delete benchmark?