Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash uniq vs Array.from(new Set()) vs spread new Set() v3 strings vs loop
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0
Browser:
Firefox 129
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Spread
4146.3 Ops/sec
use lodash
4607.8 Ops/sec
Array.from
4324.5 Ops/sec
just set
4011.2 Ops/sec
Loop
2811.0 Ops/sec
HTML Preparation code:
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js'></script> <script> const arr = (new Array(10000)).fill().map(e => "asd" + String.fromCharCode(Math.floor(97 + Math.random() * 25))); </script>
Tests:
Spread
return [...new Set(arr)]
use lodash
return _.uniq(arr);
Array.from
return Array.from( new Set(arr) );
just set
new Set(arr)
Loop
const res = new Set() for (let i of arr) { res.add(i) }