Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array concat speed
(version: 0)
Comparing performance of:
Array.prototype.concat vs spread operator vs Push vs Object assign vs For loop
Created:
4 years ago
by:
Guest
Jump to the latest result
Tests:
Array.prototype.concat
var testArray = [29, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63]; var other = [].concat(testArray);
spread operator
var testArray = [29, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63]; var other = [ ...testArray ]
Push
var testArray = [29, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63]; var other = [].push(...testArray);
Object assign
var testArray = [29, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63]; var other = Object.assign([], testArray);
For loop
var testArray = [29, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63, 27, 28, 838, 22, 2882, 2, 93, 84, 74, 7, 933, 3754, 3874, 22838, 38464, 3837, 82424, 2927, 2625, 63]; var other = [] for (let i = 0; i < testArray.length; i++){ other.push(testArray[i]) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Array.prototype.concat
spread operator
Push
Object assign
For loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It looks like you've provided two pieces of data: a benchmarking result and some code snippets. The benchmarking result is in the format expected by BenchmarkJS, which allows for the comparison of different JavaScript implementations (e.g., V8, SpiderMonkey) to determine which one performs better on a given test case. Here's a breakdown of the benchmark result: 1. **RawUAString**: The user agent string returned by the browser. 2. **Browser**: The name and version of the browser being used. 3. **DevicePlatform**: The type of device being used (in this case, desktop). 4. **OperatingSystem**: The operating system being used (in this case, Mac OS X 10.15.7). 5. **ExecutionsPerSecond**: A measure of how many iterations of the test were performed per second. 6. **TestName**: The name of the benchmarking test. The code snippets appear to be examples of different ways to perform a simple operation: 1. **spread operator**: Using the spread operator (`...`) to expand an array into separate arguments. 2. **Array.prototype.concat()**: Using the `concat()` method to concatenate two arrays. 3. **For loop**: Using a traditional `for` loop to iterate over an array and push each element onto another array. 4. **Push**: Using the `push()` method to add elements to an array. Without more context or information about what these tests are intended to measure, it's difficult to provide further insights. However, if you'd like to discuss the results of these benchmarks or explore possible optimizations for your specific use case, I'm here to help!
Related benchmarks:
Array push vs spread vs concat large
.concat vs. spread
Concat vs Spread for Large Arrayss
Spread operator vs Array.prototype.concat()
Array 2000 spread vs concat
Comments
Confirm delete:
Do you really want to delete benchmark?