chakra-core / chakra-core/ChakraCore
Optimize divide to use int divide when floating point result isn't needed
Open
Performance
Task
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Motivated by perf issues in this microbenchmark brought up in #3828. We should be able to figure out that result is only used as an int, and therefore use int division.
````js
const buffer = new Uint16Array(5000000);
start = new Date();
function bar() {
for (let i = 0, len = buffer.length; i < len; i++) {
let idiv = 1;
let size = 1;
if (i) {
idiv = i;
size = i << 16;
}
const n = i * 8 / 6;
buffer[i] = n;
}
}
for (let i = 0; i < 100; ++i) {
bar()
}
console.log(new Date() - start)
````
Contributor guide
Assessment
This issue has not been assessed yet.