LSystemEngine/SimpleTurtle/Utilities/Timer.cs

36 lines
No EOL
555 B
C#
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
}
}
}