Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
concat vs push vs spread performance(more data)
(version: 0)
Compare the new ES6 spread operator with the traditional concat() method and push
Comparing performance of:
Concat vs Spread operator vs Push
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
Concat
var a = [ "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7 ]; var b = [ 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 ]; var c = a.concat(b);
Spread operator
var a = [ "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7 ]; var b = [ 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 ]; var c = [ ...a, ...b ]
Push
var a = [ "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7, "hello", true, 7 ]; var b = [ 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 ]; var c = a.push(...b);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Concat
Spread operator
Push
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser/OS:
Chrome 121 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Concat
8177031.0 Ops/sec
Spread operator
6484919.5 Ops/sec
Push
5741475.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll provide the answer without skipping any necessary steps. To compare the performance of `Concat`, `Spread operator`, and `Push` methods in JavaScript, we need to analyze the benchmark results provided. Here are the results for each method: 1. **Concat**: * Browser: Chrome 121 * DevicePlatform: Desktop * OperatingSystem: Windows * ExecutionsPerSecond: 8177031.0 2. **Spread operator**: * Browser: Chrome 121 * DevicePlatform: Desktop * OperatingSystem: Windows * ExecutionsPerSecond: 6484919.5 3. **Push**: * Browser: Chrome 121 * DevicePlatform: Desktop * OperatingSystem: Windows * ExecutionsPerSecond: 5741475.0 Based on these results, the performance order from best to worst is: 1. `Concat` (8177031.0 executions per second) 2. `Spread operator` (6484919.5 executions per second) 3. `Push` (5741475.0 executions per second) The `Concat` method appears to be the fastest, followed by the `Spread operator`, and then the `Push` method. However, it's essential to consider that these results might vary depending on the specific use case and input data. Please note that this analysis is based solely on the provided benchmark results and may not reflect real-world scenarios or different JavaScript environments.
Related benchmarks:
Array concat vs spread operator vs push #3
spread operator vs push Brian
spread operator vs push Brian2
Array concat vs spread operator vs push larger list
Array push vs spread when reducing over results
Comments
Confirm delete:
Do you really want to delete benchmark?