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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser:
Chrome 144
Operating system:
Linux
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
Javascript Set Union
4686.7 Ops/sec
Javascript Set Union using add
5785.2 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)