Modeled after Grant Skinner’s ActionScript project PerformanceTest, I’ve made a variation designed for OpenFL to benchmark segments of Haxe code.
Executing a batch of tests every 50-milliseconds on a Timer, each iteration runs a defined number of loops for multiple samples. Overhead baseline is removed from the result, and deviation of each iteration is denoted.
Download the source code at GitHub
Please feel free to recommend tests or pull request new tests over.
Here are some sample results:
Float math
Addition, subtraction, multiplication, and division on a floating point number.
Object instantiation
Instantiating new instances.
Casting
Casting instances to different types. Downcast tests casting a MovieClip to a DisplayObject. Upcast tests casting a DisplayObject to a MovieClip.
Event dispatching
Dispatching events with and without a listener added.
Function inlining
Function call overhead versus inlining functions.
Loops
For, while, and do while loops both incrementing and decrementing.
Note that Haxe for
loop range operate can’t iterate backwards; therefore, there is no decrement for loop test, as in:
for (i in 10000 ... 0) {}
Graphics
Line drawing applied to a Shape instance.
Note that Flash drawPath
appears in error; therefore, is not included in the test results below.
Note that HTML5 does not implement drawPath
functionality.