private void PrintEventSummary(int repeatCount) { List <List <PerformanceLogger.EventTime> > events; lock (_events) { events = _events; _events = new List <List <PerformanceLogger.EventTime> >(); events.Add(PerformanceLogger.Take().ToList()); } Console.WriteLine("{0,-20}{1,8}{2,8}{3,8}{4,8}", "Event", "25%", "50%", "75%", "Count" ); var categories = events.SelectMany(i => i).GroupBy(e => e.Name).ToList(); foreach (var category in categories.OrderBy(g => g.Key)) { var times = category.Select(e => e.Duration).ToList(); times.Sort(); Console.WriteLine("{0,-20}{1,8}{2,8}{3,8}{4,8}", category.Key, times[times.Count / 4], times[times.Count / 2], times[times.Count / 4 * 3], times.Count / repeatCount ); } }
void PerformanceLogger_DumpEvents(object sender, EventArgs e) { var events = PerformanceLogger.Take().ToList(); lock (_events) { _events.Add(events); } }