Skip to content
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

Fix - incorrect table markdown #2545 #2565

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions src/BenchmarkDotNet/Exporters/MarkdownExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ private void PrintTable(SummaryTable table, ILogger logger)
logger.WriteStatistic(ColumnsStartWithSeparator ? TableHeaderSeparator.TrimStart().TrimEnd() + "-" : "-");

logger.WriteLineStatistic(string.Join("",
table.Columns.Where(c => c.NeedToShow).Select(column =>
table.Columns.Where(c => c.NeedToShow).Select((column, index) =>
new string('-', column.Width - 1) + GetHeaderSeparatorIndicator(column.OriginalColumn.IsNumeric) +
GetHeaderSeparatorColumnDivider(column.Index, table.ColumnCount))));
GetHeaderSeparatorColumnDivider(index, table.Columns.Where(c => c.NeedToShow).Count()))));
}

int rowCounter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using JetBrains.Annotations;
using VerifyXunit;
using Xunit;
using BenchmarkDotNet.Columns;

namespace BenchmarkDotNet.Tests.Exporters
{
Expand All @@ -40,9 +41,9 @@ public Task GroupExporterTest(Type benchmarkType)

var logger = new AccumulationLogger();
logger.WriteLine("=== " + benchmarkType.Name + " ===");

bool hasHideColumnsAttribute = benchmarkType.IsDefined(typeof(HideColumnsAttribute), false);
var exporter = MarkdownExporter.Mock;
var summary = MockFactory.CreateSummary(benchmarkType);
var summary = hasHideColumnsAttribute ? MockFactory.CreateSummary(benchmarkType, new ColumnHidingByNameRule("StdDev")) : MockFactory.CreateSummary(benchmarkType);
timcassell marked this conversation as resolved.
Show resolved Hide resolved
exporter.ExportToLog(summary, logger);

var validator = BaselineValidator.FailOnError;
Expand Down Expand Up @@ -219,8 +220,8 @@ public class JobBaseline_MethodsParamsJobs
[SimpleJob(id: "Job1", baseline: true), SimpleJob(id: "Job2")]
public class MethodJobBaseline_MethodsJobs
{
[Benchmark(Baseline = true)] public void Foo() {}
[Benchmark] public void Bar() {}
[Benchmark(Baseline = true)] public void Foo() { }
[Benchmark] public void Bar() { }
}

[RankColumn, LogicalGroupColumn, BaselineColumn]
Expand All @@ -229,25 +230,25 @@ public class MethodJobBaseline_MethodsJobsParams
{
[Params(2, 10), UsedImplicitly] public int Param;

[Benchmark(Baseline = true)] public void Foo() {}
[Benchmark] public void Bar() {}
[Benchmark(Baseline = true)] public void Foo() { }
[Benchmark] public void Bar() { }
}

/* Invalid */

[RankColumn, LogicalGroupColumn, BaselineColumn]
public class Invalid_TwoMethodBaselines
{
[Benchmark(Baseline = true)] public void Foo() {}
[Benchmark(Baseline = true)] public void Bar() {}
[Benchmark(Baseline = true)] public void Foo() { }
[Benchmark(Baseline = true)] public void Bar() { }
}

[RankColumn, LogicalGroupColumn, BaselineColumn]
[SimpleJob(id: "Job1", baseline: true), SimpleJob(id: "Job2", baseline: true)]
public class Invalid_TwoJobBaselines
{
[Benchmark] public void Foo() {}
[Benchmark] public void Bar() {}
[Benchmark] public void Foo() { }
[Benchmark] public void Bar() { }
}

/* Escape Params */
Expand All @@ -260,6 +261,13 @@ public class Escape_ParamsAndArguments
[Benchmark] public void Foo(char charArg) {}
[Benchmark] public void Bar() {}
}

/* Hide Column */
[HideColumns("StdDev")]
timcassell marked this conversation as resolved.
Show resolved Hide resolved
public class HideColumns_TableMarkDown
{
[Benchmark] public void Foo() { }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
=== HideColumns_TableMarkDown ===

BenchmarkDotNet v0.10.x-mock, Microsoft Windows NT 10.0.x.mock (Hyper-V)
MockIntel Core i7-6700HQ CPU 2.60GHz (Max: 3.10GHz), 1 CPU, 8 logical and 4 physical cores
Frequency: 2531248 Hz, Resolution: 395.062 ns, Timer: TSC
[Host] : Clr 4.0.x.mock, 64mock RyuJIT-v4.6.x.mock CONFIGURATION
DefaultJob : extra output line

StdDev=8.80 ns

Method | Mean | Error |
------- |---------:|--------:|
Foo | 114.5 ns | 5.88 ns |

Errors: 0
4 changes: 2 additions & 2 deletions tests/BenchmarkDotNet.Tests/Mocks/MockFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace BenchmarkDotNet.Tests.Mocks
{
public static class MockFactory
{
public static Summary CreateSummary(Type benchmarkType)
public static Summary CreateSummary(Type benchmarkType, params IColumnHidingRule[] columHidingRules)
{
var runInfo = BenchmarkConverter.TypeToBenchmarks(benchmarkType);
return new Summary(
Expand All @@ -36,7 +36,7 @@ public static Summary CreateSummary(Type benchmarkType)
TimeSpan.FromMinutes(1),
TestCultureInfo.Instance,
ImmutableArray<ValidationError>.Empty,
ImmutableArray<IColumnHidingRule>.Empty);
ImmutableArray.Create<IColumnHidingRule>(columHidingRules));
}

public static Summary CreateSummary(IConfig config) => new Summary(
Expand Down