Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Converting a small Set to an Array
(version: 1)
Return a new Array containing all elements in a Set in insertion order.
Comparing performance of:
Spread operator (...) vs Array.from()
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/* This "JavaScript preparation code" is executed just once in each run. Therefore, although `s` randomly generated, consistency is unaffected because the same object is used across all test cases below. */ const s = new Set(); for (let i = 0; i < 10; ++i) { s.add(Math.random()); }
Tests:
Spread operator (...)
const a = [...s];
Array.from()
const a = Array.from(s);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Spread operator (...)
Array.from()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Spread operator (...)
58700096.0 Ops/sec
Array.from()
56705608.0 Ops/sec
Related benchmarks:
For loop inline array.length vs captured variable
For loop inline array.length vs captured variable
Array.from vs Spread. But with one thousand sequential elements and with one thousand random elements from zero and one thousand.
array.from vs spread with set
unshift vs push
Small Array Performance with Lodash Uniq vs Native Set
Pushing vs Filling
lodash uniq vs set my 2
Please ignore this benchmark
Comments
Confirm delete:
Do you really want to delete benchmark?