haxe.Timer.stamp() vs target-specific profiler for cross-platform Haxe benchmarks
0 reputation · 28 Apr 2020, 04:24 UTC
Goal
Identify the runtime bottleneck in Haxe code before optimizing a build targeting JavaScript and C++. The measurement must stay valid in release builds and reflect target-specific JIT warm-up and garbage collection.
Constraints
haxe.Timer.stamp() is portable but measures only wall-clock time on the calling thread, with resolution varying between C++/Neko and older JavaScript engines. Release builds may eliminate the benchmark loop unless guarded with @:noInline. Target-specific profilers capture CPU sampling, allocations, and GC pauses, but require separate scripts per target and may map incompletely to inlined Haxe functions. haxe.Profiler exists in Haxe 4.2+ yet needs manual start/stop calls and offers no automatic sampling.
Uncertainty
Because V8, the JVM, and HL/JIT warm up differently, one Timer run may not reflect steady-state behavior, while per-target profiler configuration adds maintenance. I need to decide whether portable Timer benchmarks with conditional compilation or target-specific profiling is the more reliable signal per release target.
Which approach gives a more reliable bottleneck signal across JavaScript and C++: portable haxe.Timer.stamp() benchmarks or target-specific profilers? Can Timer measurements account for JIT warm-up and GC variance without automatic sampling? Should manual haxe.Profiler instrumentation be added when a target profiler is unavailable?