Ejemplo n.º 1
0
        public PerformanceSummary GetSummary()
        {
            PerformanceSummary summary = new PerformanceSummary();

            summary.TotalTime = new TimeSpan();
            ForEach(d => summary.TotalTime += d.TimeSpan);

            summary.Hits    = Count;
            summary.Minimum = Find(d => d.TimeSpan == this.Min(dp => dp.TimeSpan));
            summary.Maximum = Find(d => d.TimeSpan == this.Max(dp => dp.TimeSpan));

            return(summary);
        }
        public static ObjectDump GetObjectDump(PerformanceSummary target)
        {
            var dump = new ObjectDump();

            dump.Headers.AddRange(new [] { "Name", "Hits", "Total (ms)", "Average (ms)", "Maximum (ms)", "Minimum (ms)" });
            dump.Data.AddRange(new[] {
                target.Name,
                target.Hits.ToString().PadLeft(5, ' '),
                target.TotalTime.TotalMilliseconds.ToString("N2").PadLeft(10, ' '),
                target.AverageMilliseconds.ToString("N2").PadLeft(12, ' '),
                target.Maximum.ToString(PerformancePointOutputOptions.WithStartTime)
                , target.Minimum.ToString(PerformancePointOutputOptions.WithStartTime)
            });

            return(dump);
        }
Ejemplo n.º 3
0
        private string GetSummaryPlain()
        {
            // Collate the data
            Dictionary <string, PerformancePointCollection> grouped = new Dictionary <string, PerformancePointCollection>();

            lock (_dataPoints)
            {
                foreach (PerformancePoint datum in _dataPoints)
                {
                    if (!grouped.ContainsKey(datum.Name))
                    {
                        grouped.Add(datum.Name, new PerformancePointCollection());
                    }
                    grouped[datum.Name].Add(datum);
                }
            }

            List <PerformanceSummary> perfSummarys = new List <PerformanceSummary>();

            foreach (string key in grouped.Keys)
            {
                PerformanceSummary summary = grouped[key].GetSummary();
                summary.Name = key;
                perfSummarys.Add(summary);
            }

            perfSummarys.Sort((p1, p2) => p1.TotalTime.CompareTo(p2.TotalTime));

            ObjectDumper <PerformanceSummary> tableDump = new ObjectDumper <PerformanceSummary>(PerformanceSummary.GetObjectDump);

            var summaryString = tableDump.Dump(perfSummarys);

            if (ResetDataPointsOnRetrieval)
            {
                _dataPoints.Clear();
            }

            return(summaryString);
        }