HaxeFoundation / HaxeFoundation/hxcoro

Neko milliseconds resolution

Open
#83 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
14
Forks
0
PR merge metrics
No merged PRs in 30d

Description

I'm sure I knew this at some point, but neko's milliseconds only has seconds resolution:

```haxe
import haxe.Timer;

function main() {
var t = Timer.milliseconds();
final tEnd = t + 5000;
while (true) {
final t2 = Timer.milliseconds();
if (t2 >= tEnd) {
break;
}
if (t != t2) {
trace('$t -> $t2');
t = t2;
}

}
trace(t, tEnd);
}
```

```
source/Main.hx:12: 1769515195000 -> 1769515196000
source/Main.hx:12: 1769515196000 -> 1769515197000
source/Main.hx:12: 1769515197000 -> 1769515198000
source/Main.hx:12: 1769515198000 -> 1769515199000
source/Main.hx:17: 1769515199000, 1769515200000
```

The main issue with this is that it can turn a `delay(1)` into a `delay(1000)` with some bad luck, which is what I assume happens on the Issue37 test.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the Haxe program in the issue and inspect Neko's implementation of haxe.Timer.milliseconds. Verify the timing behavior against the Issue37 test; done means millisecond readings have sub-second resolution so a delay(1) does not become delay(1000).

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.