HaxeFoundation / HaxeFoundation/haxe
Rest arguments very slow because of allocation per call for Hashlink
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Haxe (4.3.0-rc.1+660947b):
eval: 0.244511127471923828s
js: 0.06841239801049233s
jvm: 0.03299999237060547s
hl: 4.28570699691772s (!!)
```haxe
function main() {
haxe.Timer.measure(() -> {
for (i in 0...2000000) {
test(i);
}
});
}
function test(a:...Int) {
// this is needed to make the compiler not optimize the function away
if (a[0] == 10) {
trace("hi");
}
}
```
Go: 2.394359ms
```go
package main
import (
"fmt"
"time"
)
func main() {
stamp := time.Now()
for i := 0; i < 2000000; i++ {
test(i)
}
fmt.Println(time.Since(stamp))
}
func test(a ...int) {
// this is needed to make the compiler not optimize the function away
if a[0] == 10 {
println("hi")
}
}
```
Js: 49.95563501119614ms
```js
function main() {
stamp = performance.now()
for (var i = 0; i < 2000000; i++) {
test(i);
}
console.log(performance.now() - stamp);
}
function test(...a) {
// this is needed to make the compiler not optimize the function away
if (a[0] == 10) {
console.log("hi")
}
}
main()
```
It seems that hashlink and to a much lesser amount eval is missing a faster implementation for ``haxe.Rest`` args.
Contributor guide
Assessment
This issue has not been assessed yet.