public static void Done(long lag = -1) { lock (Lock) { if (ActiveTimers.Count > 0) { var timer = ActiveTimers.Pop(); timer.Finished = Stopwatch.ElapsedTicks; double elapsed = (timer.Finished - timer.Started) / 10000.0; for (int i = 0; i < EnabledBuckets.Count; i++) { if (Match(EnabledBuckets[i], timer.Bucket)) { Console.WriteLine("{0} took {1}ms", timer.Bucket, elapsed); break; } } if (LogLag && lag != -1 && elapsed > lag) { Console.WriteLine("{0} is lagging by {1}ms", timer.Bucket, elapsed); } } } }
public static void Start(string bucket) { lock (Lock) ActiveTimers.Push(new ActiveTimer { Started = Stopwatch.ElapsedTicks, Finished = -1, Bucket = bucket }); }
public void Stop() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } foreach (System.Timers.Timer tmr in this.ActiveTimers) { tmr.Stop(); tmr.Dispose(); } ActiveTimers.Clear(); ActiveTimeBlocks.Clear(); if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }