private Summary(string title, HostEnvironmentInfo hostEnvironmentInfo, IConfig config, string resultsDirectoryPath, TimeSpan totalTime, ValidationError[] validationErrors, Benchmark[] benchmarks, BenchmarkReport[] reports)
     : this(title, hostEnvironmentInfo, config, resultsDirectoryPath, totalTime, validationErrors)
 {
     Benchmarks = benchmarks;
     Table = new SummaryTable(this);
     Reports = reports ?? new BenchmarkReport[0];
 }
        private void PrintTable(SummaryTable table, ILogger logger)
        {
            if (table.FullContent.Length == 0)
            {
                logger.WriteLineError("<pre>There are no benchmarks found</pre>");
                return;
            }

            logger.Write("<pre><code>");
            table.PrintCommonColumns(logger);
            logger.WriteLine("</code></pre>");
            logger.WriteLine();

            logger.WriteLine("<table>");

            logger.Write("<tr>");
            table.PrintLine(table.FullHeader, logger, "<th>", "</th>");
            logger.Write("</tr>");

            foreach (var line in table.FullContent)
            {
                logger.Write("<tr>");
                table.PrintLine(line, logger, "<td>", "</td>");
                logger.Write("</tr>");
            }

            logger.WriteLine("</table>");
        }
        private void PrintTable(SummaryTable table, ILogger logger)
        {
            if (table.FullContent.Length == 0)
            {
                logger.WriteLineError("There are no benchmarks found ");
                logger.NewLine();
                return;
            }
            table.PrintCommonColumns(logger);
            logger.NewLine();

            if (useCodeBlocks)
            {
                logger.Write("```");
                logger.NewLine();
            }

            table.PrintLine(table.FullHeader, logger, "", " |");
            logger.NewLine();
            logger.WriteLineStatistic(string.Join("", table.Columns.Where(c => c.NeedToShow).Select(c => new string('-', c.Width) + " |")));
            foreach (var line in table.FullContent)
            {
                table.PrintLine(line, logger, "", " |");
                logger.NewLine();
            }
        }
 public SummaryTableColumn(SummaryTable table, int index, bool alwaysShow)
 {
     Index = index;
     Header = table.FullHeader[index];
     Content = table.FullContent.Select(line => line[index]).ToArray();
     NeedToShow = alwaysShow || Content.Distinct().Count() > 1;
     Width = Math.Max(Header.Length, Content.Any() ? Content.Max(line => line.Length) : 0) + 1;
     IsDefault = table.IsDefault[index];
 }
 private SummaryTable CreateTable()
 {
     var logger = new AccumulationLogger();
     var config = DefaultConfig.Instance;
     var summary = MockFactory.CreateSummary(config);
     var table = new SummaryTable(summary);
     MarkdownExporter.Default.ExportToLog(summary, logger);
     output.WriteLine(logger.GetLog());
     return table;
 }
        private static string BuildStandardText(SummaryTable table, string[] line, string leftDel, string rightDel, int columnIndex)
        {
            var buffer = GetClearBuffer();

            buffer.Append(leftDel);
            PadLeft(table, line, leftDel, rightDel, columnIndex, buffer);
            buffer.Append(line[columnIndex]);
            buffer.Append(rightDel);

            return buffer.ToString();
        }
 public SummaryTableColumn(SummaryTable table, int index, bool alwaysShow)
 {
     Index = index;
     Header = table.FullHeader[index];
     Content = table.FullContent.Select(line => line[index]).ToArray();
     NeedToShow = alwaysShow || Content.Distinct().Count() > 1;
     Width = Math.Max(Header.Length, Content.Any() ? Content.Max(line => line.Length) : 0) + 1;
     IsTrivial = Header.IsOneOf("Platform", "Jit", "Framework", "Runtime", "LaunchCount", "WarmupCount", "TargetCount", "Affinity", "Toolchain") &&
                 Content.Distinct().Count() == 1 &&
                 Content.First().IsOneOf("Host", "Auto", "Classic");
 }
        public static void PrintLine(this SummaryTable table, string[] line, ILogger logger, string leftDel, string rightDel)
        {
            for (int columnIndex = 0; columnIndex < table.ColumnCount; columnIndex++)
            {
                if (table.Columns[columnIndex].NeedToShow)
                {
                    logger.WriteStatistic(BuildStandardText(table, line, leftDel, rightDel, columnIndex));
                }
            }

            logger.WriteLine();
        }
        private static void PadLeft(SummaryTable table, string[] line, string leftDel, string rightDel, int columnIndex, StringBuilder buffer)
        {
            const char space      = ' ';
            const int  extraWidth = 2; // " |".Length is not included in the column's Width

            var repeatCount = table.Columns[columnIndex].Width + extraWidth - leftDel.Length - line[columnIndex].Length - rightDel.Length;

            if (repeatCount > 0)
            {
                buffer.Append(space, repeatCount);
            }
        }
Beispiel #10
0
            public SummaryTableColumn(SummaryTable table, int index, IColumn column)
            {
                Index          = index;
                Header         = table.FullHeader[index];
                Content        = table.FullContent.Select(line => line[index]).ToArray();
                NeedToShow     = column.AlwaysShow || Content.Distinct().Count() > 1;
                Width          = Math.Max(Header.Length, Content.Any() ? Content.Max(line => line.Length) : 0) + 1;
                IsDefault      = table.IsDefault[index];
                OriginalColumn = column;

                Justify = column.IsNumeric ? TextJustification.Right : TextJustification.Left;
            }
        private static string BuildBoldText(SummaryTable table, string[] line, string leftDel, string rightDel, int columnIndex)
        {
            const string markdownBold = "**";

            var buffer = GetClearBuffer();

            buffer.Append(leftDel);
            PadLeft(table, line, leftDel, rightDel, columnIndex, buffer);
            buffer.Append(markdownBold);
            buffer.Append(line[columnIndex]);
            buffer.Append(markdownBold);
            buffer.Append(rightDel);

            return(buffer.ToString());
        }
Beispiel #12
0
        public Summary(string title, IList<BenchmarkReport> reports, EnvironmentHelper hostEnvironmentHelper, IConfig config, string currentDirectory, TimeSpan totalTime)
        {
            Title = title;
            HostEnvironmentHelper = hostEnvironmentHelper;
            Config = config;
            CurrentDirectory = currentDirectory;
            TotalTime = totalTime;

            Reports = new Dictionary<Benchmark, BenchmarkReport>();
            Benchmarks = reports.Select(r => r.Benchmark).ToArray();
            foreach (var report in reports)
                Reports[report.Benchmark] = report;

            TimeUnit = TimeUnit.GetBestTimeUnit(reports.Where(r => r.ResultStatistics != null).Select(r => r.ResultStatistics.Mean).ToArray());
            Table = new SummaryTable(this);
        }
Beispiel #13
0
        public Summary(string title, IList<BenchmarkReport> reports, HostEnvironmentInfo hostEnvironmentInfo, IConfig config, string resultsDirectoryPath, TimeSpan totalTime, ValidationError[] validationErrors)
            : this(title, hostEnvironmentInfo, config, resultsDirectoryPath, totalTime, validationErrors)
        {
            Benchmarks = reports.Select(r => r.Benchmark).ToArray();
            foreach (var report in reports)
                reportMap[report.Benchmark] = report;
            Reports = Benchmarks.Select(b => reportMap[b]).ToArray();

            var orderProvider = config.GetOrderProvider() ?? DefaultOrderProvider.Instance;
            Benchmarks = orderProvider.GetSummaryOrder(Benchmarks, this).ToArray();
            Reports = Benchmarks.Select(b => reportMap[b]).ToArray();

            TimeUnit = TimeUnit.GetBestTimeUnit(reports.Where(r => r.ResultStatistics != null).Select(r => r.ResultStatistics.Mean).ToArray());
            Table = new SummaryTable(this);
            shortInfos = new Dictionary<IJob, string>();
            jobs = new Lazy<IJob[]>(() => Benchmarks.Select(b => b.Job).ToArray());
        }
Beispiel #14
0
        public Summary(string title, IList <BenchmarkReport> reports, EnvironmentHelper hostEnvironmentHelper, IConfig config, string currentDirectory, TimeSpan totalTime)
        {
            Title = title;
            HostEnvironmentHelper = hostEnvironmentHelper;
            Config           = config;
            CurrentDirectory = currentDirectory;
            TotalTime        = totalTime;

            Reports    = new Dictionary <Benchmark, BenchmarkReport>();
            Benchmarks = reports.Select(r => r.Benchmark).ToArray();
            foreach (var report in reports)
            {
                Reports[report.Benchmark] = report;
            }

            TimeUnit = TimeUnit.GetBestTimeUnit(reports.Where(r => r.ResultStatistics != null).Select(r => r.ResultStatistics.Mean).ToArray());
            Table    = new SummaryTable(this);
        }
Beispiel #15
0
        public Summary(string title, IList <BenchmarkReport> reports, HostEnvironmentInfo hostEnvironmentInfo, IConfig config, string resultsDirectoryPath, TimeSpan totalTime, ValidationError[] validationErrors)
            : this(title, hostEnvironmentInfo, config, resultsDirectoryPath, totalTime, validationErrors)
        {
            Benchmarks = reports.Select(r => r.Benchmark).ToArray();
            foreach (var report in reports)
            {
                reportMap[report.Benchmark] = report;
            }
            Reports = Benchmarks.Select(b => reportMap[b]).ToArray();

            var orderProvider = config.GetOrderProvider() ?? DefaultOrderProvider.Instance;

            Benchmarks = orderProvider.GetSummaryOrder(Benchmarks, this).ToArray();
            Reports    = Benchmarks.Select(b => reportMap[b]).ToArray();

            TimeUnit   = TimeUnit.GetBestTimeUnit(reports.Where(r => r.ResultStatistics != null).Select(r => r.ResultStatistics.Mean).ToArray());
            Table      = new SummaryTable(this);
            shortInfos = new Dictionary <IJob, string>();
            jobs       = new Lazy <IJob[]>(() => Benchmarks.Select(b => b.Job).ToArray());
        }
Beispiel #16
0
            public SummaryTableColumn(SummaryTable table, int index, IColumn column, bool hide = false)
            {
                Index          = index;
                Header         = table.FullHeader[index];
                Content        = table.FullContent.Select(line => line[index]).ToArray();
                Width          = Math.Max(Header.Length, Content.Any() ? Content.Max(line => line.Length) : 0) + 1;
                IsDefault      = table.IsDefault[index];
                OriginalColumn = column;

                Justify = column.IsNumeric ? TextJustification.Right : TextJustification.Left;

                bool needToShow = column.AlwaysShow || Content.Distinct().Count() > 1;

                NeedToShow = !hide && needToShow;
                WasHidden  = hide && needToShow;

                bool isCommon = !NeedToShow && !IsDefault;

                IsCommon = (!hide && isCommon) || (hide && Content.Distinct().Count() == 1);
            }
        private static void PrintTable(SummaryTable table, ILogger logger)
        {
            if (table.FullContent.Length == 0)
            {
                logger.WriteLine("[WARNING]");
                logger.WriteLine("====");
                logger.WriteLineError("There are no benchmarks found ");
                logger.WriteLine("====");
                logger.WriteLine();
                return;
            }

            table.PrintCommonColumns(logger);
            logger.WriteLine("....");

            logger.WriteLine("[options=\"header\"]");
            logger.WriteLine("|===");
            table.PrintLine(table.FullHeader, logger, "|", string.Empty);
            foreach (var line in table.FullContent)
                table.PrintLine(line, logger, "|", string.Empty);
            logger.WriteLine("|===");
        }
Beispiel #18
0
        public static void PrintCommonColumns(this SummaryTable table, ILogger logger)
        {
            var commonColumns = table.Columns.Where(c => !c.NeedToShow && !c.IsDefault).ToArray();

            if (commonColumns.Any())
            {
                var paramsOnLine = 0;
                foreach (var column in commonColumns)
                {
                    logger.WriteInfo($"{column.Header}={column.Content[0]}  ");
                    paramsOnLine++;
                    if (paramsOnLine == 3)
                    {
                        logger.WriteLine();
                        paramsOnLine = 0;
                    }
                }
                if (paramsOnLine != 0)
                {
                    logger.WriteLine();
                }
            }
        }
        private void PrintTable(SummaryTable table, ILogger logger)
        {
            if (table.FullContent.Length == 0)
            {
                logger.WriteLineError("There are no benchmarks found ");
                logger.WriteLine();
                return;
            }

            table.PrintCommonColumns(logger);
            logger.WriteLine();

            if (useCodeBlocks)
            {
                logger.Write("```");
                logger.WriteLine();
            }

            table.PrintLine(table.FullHeader, logger, string.Empty, " |");
            logger.WriteLineStatistic(string.Join("", table.Columns.Where(c => c.NeedToShow).Select(c => new string('-', c.Width) + " |")));
            var rowCounter = 0;
            var highlightRow = false;
            foreach (var line in table.FullContent)
            {
                // Each time we hit the start of a new group, alternative the colour (in the console) or display bold in Markdown
                if (table.FullContentStartOfGroup[rowCounter])
                {
                    highlightRow = !highlightRow;
                }

                table.PrintLine(line, logger, string.Empty, " |", highlightRow, table.FullContentStartOfGroup[rowCounter], startOfGroupInBold);
                rowCounter++;
            }
        }
        private static void PadLeft(SummaryTable table, string[] line, string leftDel, string rightDel, int columnIndex, StringBuilder buffer)
        {
            const char space = ' ';
            const int extraWidth = 2; // " |".Length is not included in the column's Width

            var repeatCount = table.Columns[columnIndex].Width + extraWidth - leftDel.Length - line[columnIndex].Length - rightDel.Length;
            if (repeatCount > 0)
            {
                buffer.Append(space, repeatCount);
            }
        }
        private static string BuildBoldText(SummaryTable table, string[] line, string leftDel, string rightDel, int columnIndex)
        {
            const string markdownBold = "**";

            var buffer = GetClearBuffer();

            buffer.Append(leftDel);
            PadLeft(table, line, leftDel, rightDel, columnIndex, buffer);
            buffer.Append(markdownBold);
            buffer.Append(line[columnIndex]);
            buffer.Append(markdownBold);
            buffer.Append(rightDel);

            return buffer.ToString();
        }