Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.from() versus checking to see if item is already an array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Safari/605.1.15
Browser:
Safari 18
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
No check to see if there is an array
78499.5 Ops/sec
Check to see if there is an array
81389.6 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Tests:
No check to see if there is an array
const [Builder, add] = (Math.random() > 0.5) ? [Array, 'push'] : [Set, 'add']; const collection = new Builder(); for (let i = 0; i < 1000; i++) { collection[add](i); } const result = Array.from(collection);
Check to see if there is an array
const [Builder, add] = (Math.random() > 0.5) ? [Array, 'push'] : [Set, 'add']; const collection = new Builder(); for (let i = 0; i < 1000; i++) { collection[add](i); } const result = Array.isArray(collection) ? collection : Array.from(collection);