Exemplo n.º 1
0
 internal SummaryTable GetTable(SummaryStyle style) => new SummaryTable(this, style);
Exemplo n.º 2
0
        internal SummaryTable(Summary summary, SummaryStyle style = null)
        {
            Summary = summary;

            if (summary.HasCriticalValidationErrors)
            {
                Columns     = Array.Empty <SummaryTableColumn>();
                ColumnCount = 0;
                FullHeader  = Array.Empty <string>();
                FullContent = Array.Empty <string[]>();
                FullContentStartOfHighlightGroup = Array.Empty <bool>();
                FullContentWithHeader            = Array.Empty <string[]>();
                IsDefault = Array.Empty <bool>();
                return;
            }

            // Ensure we have all required data for styling
            style = style ?? summary.Style ?? SummaryStyle.Default;
            if (style.TimeUnit == null)
            {
                style = style.WithTimeUnit(TimeUnit.GetBestTimeUnit(summary.Reports.Where(r => r.ResultStatistics != null).Select(r => r.ResultStatistics.Mean)
                                                                    .ToArray()));
            }

            if (style.SizeUnit == null)
            {
                style = style.WithSizeUnit(SizeUnit.GetBestSizeUnit(summary.Reports.Select(r => r.GcStats.GetBytesAllocatedPerOperation(r.BenchmarkCase)).ToArray()));
            }

            var columns = summary.GetColumns();

            ColumnCount = columns.Length;
            FullHeader  = columns.Select(c => c.GetColumnTitle(style)).ToArray();

            FullContent = summary.Reports.Select(r => columns.Select(c => c.GetValue(summary, r.BenchmarkCase, style)).ToArray()).ToArray();
            IsDefault   = columns.Select(c => summary.Reports.All(r => c.IsDefault(summary, r.BenchmarkCase))).ToArray();

            var highlightGroupKeys = summary.BenchmarksCases.Select(b => b.Config.Orderer.GetHighlightGroupKey(b)).ToArray();

            FullContentStartOfHighlightGroup = new bool[summary.Reports.Length];
            if (highlightGroupKeys.Distinct().Count() > 1 && FullContentStartOfHighlightGroup.Length > 0)
            {
                FullContentStartOfHighlightGroup[0] = true;
                for (int i = 1; i < summary.Reports.Length; i++)
                {
                    FullContentStartOfHighlightGroup[i] = highlightGroupKeys[i] != highlightGroupKeys[i - 1];
                }
            }

            var logicalGroupKeys = summary.BenchmarksCases
                                   .Select(b => b.Config.Orderer.GetLogicalGroupKey(summary.BenchmarksCases, b))
                                   .ToArray();

            FullContentStartOfLogicalGroup = new bool[summary.Reports.Length];
            if (logicalGroupKeys.Distinct().Count() > 1 && FullContentStartOfLogicalGroup.Length > 0)
            {
                FullContentStartOfLogicalGroup[0] = true;
                for (int i = 1; i < summary.Reports.Length; i++)
                {
                    FullContentStartOfLogicalGroup[i] = logicalGroupKeys[i] != logicalGroupKeys[i - 1];
                }
            }

            SeparateLogicalGroups = summary.Orderer.SeparateLogicalGroups;

            var full = new List <string[]> {
                FullHeader
            };

            full.AddRange(FullContent);
            FullContentWithHeader = full.ToArray();

            Columns = new SummaryTableColumn[columns.Length];
            for (int i = 0; i < columns.Length; i++)
            {
                var  column = columns[i];
                bool hide   = summary.ColumnHidingRules.Any(rule => rule.NeedToHide(column));
                Columns[i] = new SummaryTableColumn(this, i, column, hide);
            }

            EffectiveSummaryStyle = style;
        }