Skip to content

Commit

Permalink
Adds Metrics Columns to Benchmark Report Output (#2458)
Browse files Browse the repository at this point in the history
* Adds Metrics Columns to Benchmark Report for XmlExporter, and adds columns for output based on Hardware Counters when using ManualConfig. Fix #2233

* Removed changes to ManualConfig that were not needed and introduced in a past commit of this PR.
  • Loading branch information
nazulg committed Nov 2, 2023
1 parent bb55e6b commit db4d8b6
Show file tree
Hide file tree
Showing 5 changed files with 1,109 additions and 292 deletions.
1 change: 1 addition & 0 deletions src/BenchmarkDotNet/Exporters/Xml/SummaryDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ internal class BenchmarkReportDto
public string MethodTitle => report.BenchmarkCase.Descriptor.WorkloadMethodDisplayInfo;
public string Parameters => report.BenchmarkCase.Parameters.PrintInfo;
public Statistics Statistics => report.ResultStatistics;
public IEnumerable<Metric> Metrics => report.Metrics.Values;
public GcStats Memory => new GcStats()
{
Gen0Collections = report.GcStats.Gen0Collections,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
using System.Threading.Tasks;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Exporters.Json;
using BenchmarkDotNet.Exporters.Xml;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Tests.Builders;
using BenchmarkDotNet.Tests.Mocks;
using BenchmarkDotNet.Tests.Reports;
using JetBrains.Annotations;
using VerifyXunit;
using Xunit;
Expand Down Expand Up @@ -51,7 +54,14 @@ public Task Exporters(string cultureInfoName)
foreach (var exporter in exporters)
{
PrintTitle(logger, exporter);
exporter.ExportToLog(MockFactory.CreateSummary(config.WithCultureInfo(cultureInfo)), logger);
exporter.ExportToLog(
MockFactory.CreateSummary(
config.WithCultureInfo(cultureInfo),
hugeSd: false,
new[]
{
new Metric(new FakeMetricDescriptor("CacheMisses", "Hardware counter 'CacheMisses' per single operation", "N0"), 7)
}), logger);
}

var settings = VerifySettingsFactory.Create();
Expand Down Expand Up @@ -98,6 +108,8 @@ private static IEnumerable<IExporter> GetExporters()
.AddColumn(StatisticColumn.Mean)
.AddColumn(StatisticColumn.StdDev)
.AddColumn(StatisticColumn.P67)
.AddHardwareCounters(HardwareCounter.CacheMisses)
.AddColumnProvider(DefaultColumnProviders.Metrics)
.AddDiagnoser(Diagnosers.MemoryDiagnoser.Default);

public void Dispose()
Expand Down
Loading

0 comments on commit db4d8b6

Please sign in to comment.