mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
更新Demo
更新Demo
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
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()}");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user