mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
40 lines
835 B
C#
40 lines
835 B
C#
using TEngine;
|
|
|
|
namespace GameBase
|
|
{
|
|
/// <summary>
|
|
/// 用于检测耗时。
|
|
/// </summary>
|
|
public class GameTickWatcher
|
|
{
|
|
private long _startTick;
|
|
|
|
public GameTickWatcher()
|
|
{
|
|
Refresh();
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
_startTick = System.DateTime.Now.Ticks;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用时。
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public float ElapseTime()
|
|
{
|
|
long endTick = System.DateTime.Now.Ticks;
|
|
return (float)((endTick - _startTick) / 10000) / 1000.0f;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 输出用时。
|
|
/// </summary>
|
|
public void LogUsedTime()
|
|
{
|
|
Log.Info($"Used Time: {this.ElapseTime()}");
|
|
}
|
|
}
|
|
} |