__spread Performance Issues
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Description
__spread
var tslib = require("tslib");
const { concat } = require('lodash')
var testPushES6 = function(abc) {
var arr1 = [1,2,3,-1]
var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40]
const arr = arr1.push(...arr2)
}
var testPush = function(abc) {
var arr1 = [1,2,3,-1]
var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40]
Array.prototype.push.apply(arr1, arr2)
}
var testPush2 = function(flag) {
var arr1 = [1,2,3,-1]
var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40]
arr1.push.apply(arr1, tslib.__spread(arr2));
}
var testConcat = function(abc) {
var arr1 = [1,2,3,-1]
var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40]
var arr = arr1.concat(arr2)
}
var testConcat = function(abc) {
var arr1 = [1,2,3,-1]
var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40]
var arr = concat(arr1, arr2)
}
var count = 1000000
var date = Date.now()
for (var i = 0; i < count; i++) {
testPushES6()
}
// 136
console.log(Date.now() - date)
var date = Date.now()
for (var i = 0; i < count; i++) {
testPush()
}
// 139
console.log(Date.now() - date)
var date = Date.now()
for (var i = 0; i < count; i++) {
testPush2()
}
// 1005
console.log(Date.now() - date)
var date = Date.now()
for (var i = 0; i < count; i++) {
testConcat()
}
// 310
console.log(Date.now() - date)
var date = Date.now()
for (var i = 0; i < count; i++) {
testConcat2()
}
// 810
console.log(Date.now() - date)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the benchmark in the issue and inspect the tslib.__spread helper it exercises. Compare its results and timing with the native spread, Array.prototype.push.apply, and concat cases shown; done would require an agreed performance improvement without changing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100