/// <summary> /// Display the timings for each counter in the dictionary. /// </summary> /// <param name="counters"></param> internal void DisplayCounters(Dictionary <string, PerformanceCounter> counters) { ArrayList perfCounters = new ArrayList(counters.Values.Count); perfCounters.AddRange(counters.Values); perfCounters.Sort(PerformanceCounter.DescendingByElapsedTimeComparer); bool reentrantCounterExists = false; WriteLinePrettyFromResourceDelegate lineWriter = WriteLinePrettyFromResource; foreach (PerformanceCounter counter in perfCounters) { if (counter.ReenteredScope) { reentrantCounterExists = true; } counter.PrintCounterMessage(lineWriter, setColor, resetColor); } if (reentrantCounterExists) { // display an explanation of why there was no value displayed WriteLinePrettyFromResource(4, "PerformanceReentrancyNote"); } }
internal virtual void PrintCounterMessage(WriteLinePrettyFromResourceDelegate WriteLinePrettyFromResource, ColorSetter setColor, ColorResetter resetColor) { string time; if (!reenteredScope) { // round: submillisecond values are not meaningful time = String.Format(CultureInfo.CurrentCulture, "{0,5}", Math.Round(elapsedTime.TotalMilliseconds, 0)); } else { // no value available; instead display an asterisk time = " *"; } WriteLinePrettyFromResource ( 2, "PerformanceLine", time, String.Format(CultureInfo.CurrentCulture, "{0,-40}" /* pad to 40 align left */, scopeName), String.Format(CultureInfo.CurrentCulture, "{0,3}", calls) ); }
internal virtual void PrintCounterMessage(WriteLinePrettyFromResourceDelegate WriteLinePrettyFromResource, ColorSetter setColor, ColorResetter resetColor) { string time; if (!reenteredScope) { // round: submillisecond values are not meaningful time = String.Format(CultureInfo.CurrentCulture, "{0,5}", Math.Round(elapsedTime.TotalMilliseconds, 0)); } else { // no value available; instead display an asterisk time = " *"; } WriteLinePrettyFromResource ( 2, "PerformanceLine", time, String.Format(CultureInfo.CurrentCulture, "{0,-40}" /* pad to 40 align left */, scopeName), String.Format(CultureInfo.CurrentCulture, "{0,3}", calls) ); }
/// <summary> /// Display the timings for each counter in the hashtable /// </summary> /// <param name="counters"></param> internal void DisplayCounters(Hashtable counters) { ArrayList perfCounters = new ArrayList(counters.Values.Count); perfCounters.AddRange(counters.Values); perfCounters.Sort(PerformanceCounter.DescendingByElapsedTimeComparer); bool reentrantCounterExists = false; WriteLinePrettyFromResourceDelegate lineWriter = new WriteLinePrettyFromResourceDelegate(WriteLinePrettyFromResource); foreach (PerformanceCounter counter in perfCounters) { if (counter.ReenteredScope) { reentrantCounterExists = true; } counter.PrintCounterMessage(lineWriter, setColor, resetColor); } if (reentrantCounterExists) { // display an explanation of why there was no value displayed WriteLinePrettyFromResource(4, "PerformanceReentrancyNote"); } }