LSystemEngine/SimpleTurtle/Utilities/Timer.cs

36 lines
555 B
C#
Raw Normal View History

using System;
namespace SBRL.Utilities
{
public class Timer
{
public DateTime StartTime { get; private set; }
public Timer() { }
public static Timer GetStarted()
{
Timer result = new Timer();
result.Start();
return result;
}
public void Start()
{
StartTime = DateTime.Now;
}
public float GetElapsedSeconds()
{
DateTime now = DateTime.Now;
TimeSpan elasped = now - StartTime;
StartTime = now;
return (float)elasped.Ticks / TimeSpan.TicksPerSecond;
}
public void Reset()
{
Start();
}
}
}