public static void Push(string label) { if (sProcess == null) { return; } CurrentCounter counter = new CurrentCounter(label, sProcess.UserProcessorTime.TotalMilliseconds); sCurrentCounters.Push(counter); }
public static void Pop() { if (sProcess == null) { return; } CurrentCounter thisCounter = sCurrentCounters.Pop(); double elapsed = sProcess.UserProcessorTime.TotalMilliseconds - thisCounter.StartTime; // build the label string longLabel = String.Empty; foreach (CurrentCounter current in sCurrentCounters) { longLabel = current.Label + "/" + longLabel; } longLabel += thisCounter.Label; Counter counter = null; if (!sCounters.ContainsKey(longLabel)) { counter = new Counter(); counter.Label = longLabel; sCounters[longLabel] = counter; } else { counter = sCounters[longLabel]; } counter.TotalTime += elapsed; counter.Count++; }