Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash uniq vs Array.from(new Set()) vs spread new Set() vs array.filter
(version: 0)
Comparing performance of:
Spread vs use lodash vs Array.from vs filter
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js'></script>
Tests:
Spread
return [...new Set([1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7])]
use lodash
return _.uniq([1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]);
Array.from
return Array.from( new Set([1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) );
filter
const arr = [1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7] return arr.filter((num,index)=> index =arr.indexOf(num) )
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Spread
use lodash
Array.from
filter
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0
Browser/OS:
Firefox 137 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Spread
1608478.2 Ops/sec
use lodash
4392147.5 Ops/sec
Array.from
1610055.1 Ops/sec
filter
1684260.0 Ops/sec
Related benchmarks:
lodash uniq vs Array.from(new Set()) vs spread new Set() with filter
Lodash union vs Native Javascript
lodash uniq vs spread new Set() medium size
lodash uniq vs set spread
Comments
Confirm delete:
Do you really want to delete benchmark?