Skip to content

Adds Metrics Columns to Benchmark Report Output #2458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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