BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

Question about IColumn.GetValue(..) and SummaryStyle

Open mawosoft opened this issue 4 years ago • 0 comments
trafficstars

I'm confused by this description of IColumn.GetValue(): https://github.com/dotnet/BenchmarkDotNet/blob/93786511bf9b2a0e2bdae45c7248ff963a750992/src/BenchmarkDotNet/Columns/IColumn.cs#L19-L27

Now my reading would be to implement this as:

public string GetValue(Summary summary, BenchmarkCase benchmarkCase) => GetValue(summary, benchmarkCase, summary.Style);
public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) => ValueWithStyle(style);

But most actual implementations do it the other way around:

public string GetValue(Summary summary, BenchmarkCase benchmarkCase)
{
    if (someColumn)
    {
        // Some use the maybe user-defined style of the summary or don't need one
        return ValueWithStyle(summary.Style);
    }
    else
    {
        // Others ignore any user-defined style and use the predefined default
        return ValueWithStyle(SummaryStyle.Default);
    }
}
// While this overload in most cases ignores the explicit style parameter
public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) => GetValue(summary, benchmarkCase);

So what am I missing here?

mawosoft avatar Aug 25 '21 01:08 mawosoft