HaxeFoundation / HaxeFoundation/hashlink

Maps are slow in hashlink

Open
#607 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
901
Forks
201
Avg merge
18h 9m
Merged PRs (30d)
8

Description

Here is my test code:

```
function mapTest() {
var start = Timer.stamp();
var N = 1000000;

var map:Map = [];
for (i in 0...N){//set
map.set(i+'', i);
}
trace("1 step time:", Timer.stamp() - start);
for (key in map.keys()){//get
var a = map.get(key);
a++;
}
trace("2 step time:", Timer.stamp() - start);
for (i in 0...N){//remove
map.remove(i+'');
}
trace("total time:", Timer.stamp() - start);
}
```

And here are my results for N = 1 000 000:
1 step time: 0.400216579437256
2 step time: 0.55933403968811
total time: 20.15642786026

Hashlink:
1000 => total time: 0.000833272933959961
10000 => total time: 0.0115585327148438
100000 => total time: 0.325639247894287
1000000 => total time: 20.6692686080933
10000000 => total time: ???

the same code compiled for Javascript:
1000 => total time: 0.0005000000000000004
10000 => total time: 0.001600000001490104
100000 => total time: 0.015400000002235181
1000000 => total time: 0.16799999999999998
10000000 => total time: 2.606199999999255

Also I tried IntMaps they're faster at setting and getting but slower at removing.

Anyway set and get are also slow. Javascript completes the whole test 2 times faster than Hashlink only step 1.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.