1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-10 00:34:40 +00:00
Funkin/source/funkin/util/TimerUtil.hx
2024-03-13 18:47:15 -07:00

31 lines
672 B
Haxe

package funkin.util;
import funkin.util.tools.FloatTools;
import haxe.Timer;
class TimerUtil
{
public static function start():Float
{
return Timer.stamp();
}
private static function took(start:Float, ?end:Float):Float
{
var endOrNow:Float = end != null ? end : Timer.stamp();
return endOrNow - start;
}
public static function seconds(start:Float, ?end:Float, ?precision = 2):String
{
var seconds:Float = FloatTools.round(took(start, end), precision);
return '${seconds} seconds';
}
public static function ms(start:Float, ?end:Float):String
{
var seconds:Float = took(start, end);
return '${seconds * 1000} ms';
}
}