Beispiel #1
0
 private static void ToCsvBenchmark(BenchmarkComparisonAnalysisResult benchmark, TextWriter outStream)
 {
     outStream.WriteLine($",Benchmark,{CsvEscape(benchmark.Benchmark.Name)}");
     outStream.WriteLine(",,Metric,Baseline Value,Candidate Value,Baseline StdDev, Candidate StdDev, % Change,Decision");
     foreach (var metric in benchmark.Metrics)
     {
         double percent = ((metric.Candidate.Value - metric.Baseline.Value) * 100) / metric.Baseline.Value;
         outStream.WriteLine($",,{CsvEscape(metric.Metric)},"
                             + $"{CsvEscape(metric.Baseline.Value.ToString())},"
                             + $"{CsvEscape(metric.Candidate.Value.ToString())},"
                             + $"{CsvEscape(metric.Baseline.StandardDeviation.ToString())},"
                             + $"{CsvEscape(metric.Candidate.StandardDeviation.ToString())},"
                             + $"{CsvEscape(percent.ToString())},"
                             + $"{CsvEscape(metric.Decision.ToString())}");
     }
 }
        private BenchmarkComparisonAnalysisResult DoSingleBenchmarkComparison(BenchmarkDataSource baseline, BenchmarkDataSource candidate)
        {
            var result           = new BenchmarkComparisonAnalysisResult();
            var baselineMetrics  = CalculateMetrics(baseline);
            var candidateMetrics = CalculateMetrics(candidate);

            foreach (var metric in baselineMetrics.Zip(candidateMetrics, Tuple.Create))
            {
                var baselineMetric  = metric.Item1;
                var candidateMetric = metric.Item2;
                var comp            = new MetricComparison();
                comp.Metric    = baselineMetric.Name;
                comp.Unit      = baselineMetric.Unit;
                comp.Baseline  = baselineMetric;
                comp.Candidate = candidateMetric;
                comp.Decision  = MakeDecision(baselineMetric, candidateMetric);
                result.Metrics.Add(comp);
            }

            result.Benchmark = baseline.Benchmark;
            return(result);
        }