using System; using Stopwatch = System.Diagnostics.Stopwatch; namespace Implab.Diagnostics { public class LogicalOperation { readonly Stopwatch m_stopwatch; public string Name { get; private set; } internal LogicalOperation(string name) { Name = string.IsNullOrEmpty(name) ? "" : name; m_stopwatch = Stopwatch.StartNew(); } public TimeSpan Elapsed { get { return m_stopwatch.Elapsed; } } public void End() { m_stopwatch.Stop(); } public override string ToString() => Name; } }