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

29 lines
730 B
C#

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