Skip to content

Commit 554ea3a

Browse files
authored
Handle case of null BytesAllocatedPerOperation in the json (#5074)
This property is nullable on the BDN side: GetBytesAllocatedPerOperation -> https://github.com/dotnet/BenchmarkDotNet/blob/master/src/BenchmarkDotNet/Engines/GcStats.cs#L41. The ResultsComparer was crashing when trying to deserialize the json results.
1 parent f7d7e64 commit 554ea3a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/tools/ResultsComparer/DataTransferContracts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class Memory
8888
public int Gen1Collections { get; set; }
8989
public int Gen2Collections { get; set; }
9090
public long TotalOperations { get; set; }
91-
public long BytesAllocatedPerOperation { get; set; }
91+
public long? BytesAllocatedPerOperation { get; set; }
9292
}
9393

9494
public class Measurement

src/tools/ResultsComparer/MultipleInputsComparer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ private static string GetRatio((string id, Benchmark baseResult, Benchmark diffR
103103

104104
private static string GetAllocatedDiff(Benchmark diffResult, Benchmark baseResult)
105105
{
106-
long baseline = baseResult.Memory.BytesAllocatedPerOperation;
106+
long baseline = baseResult.Memory.BytesAllocatedPerOperation ?? 0;
107107
if (baseline == 0)
108108
baseline = GetMetricValue(baseResult);
109-
long diff = diffResult.Memory.BytesAllocatedPerOperation;
109+
long diff = diffResult.Memory.BytesAllocatedPerOperation ?? 0;
110110
if (diff == 0)
111111
diff = GetMetricValue(diffResult);
112112

0 commit comments

Comments
 (0)