narsil/Tanshu.Accounts.PointOfSale/Profiling/BlockTimer.cs

26 lines
675 B
C#
Raw Normal View History

using System;
namespace Tanshu.Accounts.PointOfSale
{
public class BlockTimer : IDisposable
{
private readonly string _description;
private readonly long _start;
public BlockTimer(string description)
{
_description = description;
_start = DateTime.Now.Ticks;
}
public void Dispose()
{
var totalTime = DateTime.Now.Ticks - _start;
Console.WriteLine(_description);
Console.Write(" - Total Execution Time: ");
Console.Write(new TimeSpan(totalTime).TotalMilliseconds.ToString());
Console.WriteLine(" ms.");
}
}
}