Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set.union vs Set.add
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser:
Firefox 145
Operating system:
Windows
Device Platform:
Desktop
Date tested:
3 months ago
Set.add in the other order
155K/s
Set.add
147K/s
Set.union in the other order
126K/s
Set.union
120K/s
View exact numbers
Test name
Executions per second
✓
Set.add in the other order
154,963 Ops/sec
Set.add
146,915 Ops/sec
Set.union in the other order
125,720 Ops/sec
Set.union
120,095 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const setA = new Set(Array.from({ length: 10000 }, _ => Math.floor(Math.random() * 200))); const setB = new Set(Array.from({ length: 10000 }, _ => Math.floor(Math.random() * 300)));
Tests:
Set.union
const union = setA.union(setB);
Set.add
const union = new Set(setA); setB.forEach(v => union.add(v));
Set.union in the other order
const union = setB.union(setA);
Set.add in the other order
const union = new Set(setB); setA.forEach(v => union.add(v));