Created
December 28, 2014 22:31
-
-
Save MangelMaxime/fe8c8380c799eb7279fb to your computer and use it in GitHub Desktop.
FPS class Memory usage
This file contains hidden or 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
override public function update(dt:Float) { | |
var now = Timer.stamp(); | |
var memString : String; | |
this.times.push(now); | |
while (this.times[0] < now - 1) { | |
times.shift(); | |
} | |
#if cpp | |
var usage : Float = convertToMB(Gc.memInfo(Gc.MEM_INFO_USAGE)); | |
if (usage > this.memPeak) | |
this.memPeak = usage; | |
memString = "MEN : " + usage + "MB\nMEM Peak : " + this.memPeak + " MB\nMEM Reserved : " + convertToMB(Gc.memInfo(Gc.MEM_INFO_RESERVED)) + "MB"; | |
#end | |
this.set_text("FPS : " + times.length + "\n" + memString); | |
} | |
private static function convertToMB (mem : Float) { | |
return Math.round(mem / 1024 / 1024 * 100) / 100; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment