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:
5 years ago
by:
Guest
Go 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
use lodash
4.4M/s
filter
1.7M/s
Array.from
1.6M/s
Spread
1.6M/s
View exact numbers
Test name
Executions per second
✓
use lodash
4,392,148 Ops/sec
filter
1,684,260 Ops/sec
Array.from
1,610,055 Ops/sec
Spread
1,608,478 Ops/sec
Related benchmarks
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?