https://github.com/distributedlife/array-join-performance
Testing the performance of different array join approaches
https://github.com/distributedlife/array-join-performance
Last synced: 8 months ago
JSON representation
Testing the performance of different array join approaches
- Host: GitHub
- URL: https://github.com/distributedlife/array-join-performance
- Owner: distributedlife
- Created: 2016-07-22T11:24:11.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-22T11:41:45.000Z (almost 10 years ago)
- Last Synced: 2025-01-19T14:24:14.706Z (over 1 year ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Joining Array Performance
Three ways to join an array:
~~~javascript
arr = arr.concat(other);
Array.prototype.push.apply(arr, other);
arr.push(...other); //es6 spread
~~~
The results are:
~~~shell
add 1
concat x 13,014 ops/sec ±28.20% (17 runs sampled)
prototype push x 7,894,593 ops/sec ±14.93% (70 runs sampled)
es6 spread x 1,487,987 ops/sec ±4.12% (83 runs sampled)
Fastest is prototype push
add 5
concat x 3,001 ops/sec ±123.61% (7 runs sampled)
prototype push x 1,472,618 ops/sec ±24.88% (62 runs sampled)
es6 spread x 514,753 ops/sec ±9.14% (69 runs sampled)
Fastest is prototype push
add 10
concat x 1,179 ops/sec ±124.77% (5 runs sampled)
prototype push x 788,978 ops/sec ±29.39% (48 runs sampled)
es6 spread x 254,928 ops/sec ±17.68% (63 runs sampled)
Fastest is prototype push
~~~