Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Set Union using add vs. Native Set Union
(version: 1)
Comparing performance of:
Javascript Set Union vs Javascript Set Union using add
Created:
10 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>
Script Preparation code:
const first = new Set([...Array(10000)].map(it => String(~~(Math.random() * 10000)))); const second = new Set([...Array(10000)].map(it => String(~~(Math.random() * 200000)))); class MySet extends Set { union(other) { other.forEach(el => { this.add(el); }); return this; } } const firstSet = new MySet(first); const secondSet = new MySet(second);
Tests:
Javascript Set Union
first.union(second)
Javascript Set Union using add
firstSet.union(second)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Javascript Set Union
Javascript Set Union using add
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser/OS:
Chrome 144 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Javascript Set Union
4686.7 Ops/sec
Javascript Set Union using add
5785.2 Ops/sec
Related benchmarks:
Set union forEach vs forOf
for...of Set vs. array conversion
Set vs Object iteration
Has Objects vs Sets
set.add test4
Destructuring assignment vs Set iterator
Set merge
Set ES2024 Method Benchmark
{} vs Map with set
Comments
Confirm delete:
Do you really want to delete benchmark?