41 lines
1.1 KiB
Haxe
41 lines
1.1 KiB
Haxe
package engine;
|
|
|
|
import game.ui.console.Console;
|
|
import Sys;
|
|
|
|
class HProfiler{
|
|
public static var profilerList:Array<HProfiler> = [];
|
|
public static var profilerMap:Map<String, HProfiler> = [];
|
|
private var tStart:Float;
|
|
private var tEnd:Float;
|
|
public var tDelta:Float;
|
|
private var name:String;
|
|
private function new(_name:String){
|
|
name = _name;
|
|
profilerMap[_name] = this;
|
|
}
|
|
public function start(){
|
|
tStart = Sys.time() * 1000.0;
|
|
}
|
|
public function stop(){
|
|
tEnd = Sys.time() * 1000.0;
|
|
tDelta = (tEnd-tStart);
|
|
}
|
|
//public static var
|
|
public static function startProfiling(name:String):Void
|
|
{
|
|
if(profilerMap[name] == null)
|
|
profilerList.push(new HProfiler(name));
|
|
profilerMap[name].start();
|
|
}
|
|
public static function stopProfiling(name:String):Void
|
|
{
|
|
profilerMap[name].stop();
|
|
}
|
|
|
|
public static var ccmd_debug_tracetimes = ConVar.registerCCmd("debug_tracetimes", (args:Array<String>) -> {
|
|
for(profiler in profilerList){
|
|
Console.devMsg(profiler.name + ": " + profiler.tDelta + "ms");
|
|
}
|
|
});
|
|
} |