|
1 | 1 | using System.Linq;
|
2 | 2 | using BenchmarkDotNet.Reports;
|
3 | 3 | using BenchmarkDotNet.Running;
|
| 4 | +using Perfolizer.Common; |
4 | 5 | using Perfolizer.Horology;
|
5 | 6 |
|
6 | 7 | namespace BenchmarkDotNet.Columns
|
@@ -33,12 +34,15 @@ public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyl
|
33 | 34 |
|
34 | 35 | var cultureInfo = summary.GetCultureInfo();
|
35 | 36 |
|
36 |
| - if (style.PrintUnitsInContent && descriptor.UnitType == UnitType.CodeSize) |
37 |
| - return SizeValue.FromBytes((long)metric.Value).ToString(style.CodeSizeUnit, cultureInfo, descriptor.NumberFormat); |
38 |
| - if (style.PrintUnitsInContent && descriptor.UnitType == UnitType.Size) |
39 |
| - return SizeValue.FromBytes((long)metric.Value).ToString(style.SizeUnit, cultureInfo, descriptor.NumberFormat); |
40 |
| - if (style.PrintUnitsInContent && descriptor.UnitType == UnitType.Time) |
41 |
| - return TimeInterval.FromNanoseconds(metric.Value).ToString(style.TimeUnit, cultureInfo); |
| 37 | + bool printUnits = style.PrintUnitsInContent || style.PrintUnitsInHeader; |
| 38 | + UnitPresentation unitPresentation = UnitPresentation.FromVisibility(style.PrintUnitsInContent); |
| 39 | + |
| 40 | + if (printUnits && descriptor.UnitType == UnitType.CodeSize) |
| 41 | + return SizeValue.FromBytes((long)metric.Value).ToString(style.CodeSizeUnit, cultureInfo, descriptor.NumberFormat, unitPresentation); |
| 42 | + if (printUnits && descriptor.UnitType == UnitType.Size) |
| 43 | + return SizeValue.FromBytes((long)metric.Value).ToString(style.SizeUnit, cultureInfo, descriptor.NumberFormat, unitPresentation); |
| 44 | + if (printUnits && descriptor.UnitType == UnitType.Time) |
| 45 | + return TimeInterval.FromNanoseconds(metric.Value).ToString(style.TimeUnit, cultureInfo, descriptor.NumberFormat, unitPresentation); |
42 | 46 |
|
43 | 47 | return metric.Value.ToString(descriptor.NumberFormat, cultureInfo);
|
44 | 48 | }
|
|
0 commit comments