chakra-core / chakra-core/ChakraCore

Perf : filling the array is taking time

Open
#5,386 5 comments 0 reactions 0 assignees View on GitHub
Performance
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

```js
(function() {
print('Array fill with increment of 2')
var start = new Date();
let maxSize = 2**25;
let arr = new Array(maxSize);
for (i = 0; i < maxSize; i += 2) {
arr[i] = i;
}

print('time spent : ' + ((new Date()) - start));
})();

(function() {
print('Array fill with increment of 512')
var start = new Date();
let maxSize = 2**25;
let arr = new Array(maxSize);
for (i = 0; i < maxSize; i += 512) {
arr[i] = i;
}

print('time spent : ' + ((new Date()) - start));
})();
```

Output:
```
Array fill with increment of 2
time spent : 369
Array fill with increment of 512
time spent : 4196
```
This is strange - with 512 increment we should be filling less items to the array and we should be spending less time.
I suspect this may be due to more number of sparse array segment. I haven't created trace to support my theory.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.