Created
February 11, 2016 08:15
-
-
Save wighawag/2d0824b61cb5712a4def to your computer and use it in GitHub Desktop.
Haxe telemetry in a unit test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if HXCPP_TELEMETRY | |
public function testAllocation(){ | |
var instanceUnderTest = new Testing(); | |
//start telemetry | |
var threadNum = untyped __global__.__hxcpp_hxt_start_telemetry(true, true); | |
instanceUnderTest.methodThatShoulDoNoAllocation(); | |
//force gc to ensure allocation are tracked? | |
cpp.vm.Gc.run(true); | |
//stash the data | |
untyped __global__.__hxcpp_hxt_stash_telemetry(); | |
//gather the data and return the number of allocation | |
var numAllocations = getNumAllocations(threadNum); | |
Assert.equals(0, numAllocations); | |
} | |
@:functionCode(' | |
TelemetryFrame* frame = __hxcpp_hxt_dump_telemetry(thread_num); | |
if (frame->allocation_data!=0){ | |
return frame->allocation_data->size(); | |
} | |
return -1; | |
') | |
public static function getNumAllocations(thread_num : Int) : Int{ | |
return 10; | |
} | |
#end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try something like: