Example #1
0
        private static void PrintTable(ComparerResult[] notSame, string metricName, ComparisonConclusion conclusion, StreamWriter writer, ComparerOptions args)
        {
            var data = notSame
                       .Where(result => result.Conclusion == conclusion)
                       .OrderByDescending(result => conclusion.IsBetterOrWorse() ?
                                          Helpers.GetRatio(conclusion, result.BaseResult, result.DiffResult) : 0)
                       .Take(args.TopCount ?? int.MaxValue)
                       .Select(result => new
            {
                Id           = (result.Id.Length <= 80 || args.FullId) ? result.Id : result.Id.Substring(0, 80),
                DisplayValue = conclusion.IsBetterOrWorse() ? Helpers.GetRatio(conclusion, result.BaseResult, result.DiffResult).ToString() : "N/A",
                BaseMedian   = result.BaseResult?.Result,
                DiffMedian   = result.DiffResult?.Result,
                Modality     = conclusion.IsBetterOrWorse() ? GetModalInfo(result.BaseResult) ?? GetModalInfo(result.DiffResult) : "N/A"
            })
                       .ToArray();

            if (!data.Any())
            {
                writer.WriteLine($"No {conclusion} results for the provided threshold = {args.StatisticalTestThreshold} and noise filter = {args.NoiseThreshold}.");
                writer.WriteLine();
                return;
            }

            Table table = data
                          .ToMarkdownTable()
                          .WithHeaders(
                conclusion.ToString(),
                conclusion == ComparisonConclusion.Better ? "base/diff" : "diff/base",
                $"Base {metricName}",
                $"Diff {metricName}",
                "Modality");

            foreach (string line in table.ToMarkdown().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries))
            {
                writer.WriteLine($"| {line.TrimStart()}|"); // the table starts with \t and does not end with '|' and it looks bad so we fix it
            }

            writer.WriteLine();
        }
Example #2
0
 /// <summary>
 /// Whether the conclusion indicates that the diff result is different from the base result.
 /// </summary>
 /// <param name="conclusion">The conclusion to test.</param>
 /// <returns>Whether the conclusion indicates that the diff is neither better or worse than the base (could be same or unknown).</returns>
 public static bool IsDifferent(this ComparisonConclusion conclusion) =>
 conclusion != ComparisonConclusion.Same && conclusion != ComparisonConclusion.Unknown;
Example #3
0
 /// <summary>
 /// Gets the diff/base or base/diff ratio depending on which is better.
 /// </summary>
 /// <param name="conclusion">The conclusion of the result.</param>
 /// <param name="baseResult">The measured result of the base report.</param>
 /// <param name="diffResult">The measured result of the diff report.</param>
 /// <returns>The ratio between the worse result and the better result.</returns>
 public static double GetRatio(ComparisonConclusion conclusion, MeasurementResult baseResult, MeasurementResult diffResult)
 => conclusion == ComparisonConclusion.Better
         ? baseResult.Result / diffResult.Result
         : diffResult.Result / baseResult.Result;
Example #4
0
 /// <summary>
 /// Whether the conclusion is indicates that the diff is better or worse than the
 /// base result.
 /// </summary>
 /// <param name="conclusion">The conclusion to test.</param>
 /// <returns>Whether the conclusion indicates that the the diff is either better or worse than the base.</returns>
 public static bool IsBetterOrWorse(this ComparisonConclusion conclusion) =>
 conclusion == ComparisonConclusion.Better || conclusion == ComparisonConclusion.Worse;