Advertisement
PXshadow

Untitled

Jan 30th, 2018
3,103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.23 KB | None | 0 0
  1. package ;
  2.  
  3. import openfl.Lib;
  4. import openfl.system.Capabilities;
  5. import openfl.text.TextField;
  6. import openfl.events.Event;
  7. import openfl.text.TextFormat;
  8. import openfl.system.System;
  9. import haxe.Timer;
  10.  
  11. class InfoDebug extends TextField
  12. {
  13.     private var memPeak:Float = 0;
  14.     private var timer:Int = 4;
  15.     private var times:Array<Float>;
  16.     public var tL:Int = 60;
  17.     public function new(inCol:Int = 16777215)
  18.     {
  19.         super();
  20.         times = [];
  21.         selectable = false;
  22.         defaultTextFormat = new TextFormat("_sans", 15, inCol);
  23.         width = 150 * 4;
  24.         height = 70;
  25.         y = Lib.current.stage.stageHeight - 20;
  26.         Lib.current.addChild(this);
  27.         addEventListener (Event.ENTER_FRAME, this_onEnterFrame);
  28.     }
  29.    
  30.     @:noCompletion private function this_onEnterFrame (event:Event):Void {
  31.         if (timer == 0)
  32.         {
  33.         timer = 4;
  34.         var mem:Float = Math.round(System.totalMemory / 1024 / 1024 * 100)/100;
  35.         if (mem > memPeak) memPeak = mem;
  36.         //elasped
  37.         //GET framerate
  38.         var now = Timer.stamp();
  39.         times.push(now);
  40.        
  41.         while (times[0] < now - 1)
  42.             times.shift();
  43.             tL = times.length * timer;
  44.        
  45.         text = "fps " + tL + " el " + Math.round((tL / Lib.current.stage.frameRate) * 10) / 10 +  " mem " + mem + "  mx " + memPeak;
  46.         }
  47.         timer += -1;
  48.     }
  49.    
  50.    
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement