Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set Union using add vs. Native Set Union
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0
Browser:
Firefox 145
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
Javascript Set Union
1318.2 Ops/sec
Javascript Set Union using add
3212.5 Ops/sec
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)