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:
22 days ago
Test name
Executions per second
Set.union
120095.4 Ops/sec
Set.add
146914.9 Ops/sec
Set.union in the other order
125719.5 Ops/sec
Set.add in the other order
154962.6 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));