Skip to content

Commit 2bc61ca

Browse files
committed
chore: remove SimpleJson library dependency
1 parent 25914b8 commit 2bc61ca

12 files changed

Lines changed: 1480 additions & 3607 deletions

src/BenchmarkDotNet/Exporters/Json/JsonExporterBase.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
using System.Collections.Generic;
2-
using System.Linq;
3-
using BenchmarkDotNet.Environments;
1+
using BenchmarkDotNet.Environments;
42
using BenchmarkDotNet.Loggers;
53
using BenchmarkDotNet.Reports;
4+
using BenchmarkDotNet.Serialization;
65
using Perfolizer.Helpers;
76
using Perfolizer.Horology;
8-
using SimpleJson;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
10+
#nullable enable
911

1012
namespace BenchmarkDotNet.Exporters.Json
1113
{
@@ -24,8 +26,9 @@ protected JsonExporterBase(bool indentJson = false, bool excludeMeasurements = f
2426

2527
public override void ExportToLog(Summary summary, ILogger logger)
2628
{
27-
SimpleJsonSerializer.CurrentJsonSerializerStrategy.Indent = IndentJson;
28-
logger.WriteLine(SimpleJsonSerializer.SerializeObject(GetDataToSerialize(summary)));
29+
var dataToSerialize = GetDataToSerialize(summary);
30+
var json = BdnSimpleJsonSerializer.Serialize(dataToSerialize, IndentJson);
31+
logger.WriteLine(json);
2932
}
3033

3134
protected virtual IReadOnlyDictionary<string, object> GetDataToSerialize(Summary summary)
@@ -40,11 +43,11 @@ protected virtual IReadOnlyDictionary<string, object> GetDataToSerialize(Summary
4043
};
4144
}
4245

43-
protected virtual IReadOnlyDictionary<string, object> GetDataToSerialize(HostEnvironmentInfo environmentInfo)
46+
protected virtual IReadOnlyDictionary<string, object?> GetDataToSerialize(HostEnvironmentInfo environmentInfo)
4447
{
4548
// We construct HostEnvironmentInfo manually, so that we can have the HardwareTimerKind enum as text, rather than an integer
4649
// SimpleJson serializer doesn't seem to have an enum String/Value option (to-be-fair, it is meant to be "Simple")
47-
return new Dictionary<string, object>
50+
return new Dictionary<string, object?>
4851
{
4952
{ nameof(HostEnvironmentInfo.BenchmarkDotNetCaption), HostEnvironmentInfo.BenchmarkDotNetCaption },
5053
{ nameof(environmentInfo.BenchmarkDotNetVersion), environmentInfo.BenchmarkDotNetVersion },
@@ -64,9 +67,9 @@ protected virtual IReadOnlyDictionary<string, object> GetDataToSerialize(HostEnv
6467
};
6568
}
6669

67-
protected virtual IReadOnlyDictionary<string, object> GetDataToSerialize(BenchmarkReport report)
70+
protected virtual IReadOnlyDictionary<string, object?> GetDataToSerialize(BenchmarkReport report)
6871
{
69-
var benchmark = new Dictionary<string, object>
72+
var benchmark = new Dictionary<string, object?>
7073
{
7174
// We don't need Benchmark.ShortInfo, that info is available via Benchmark.Parameters below
7275
{ "DisplayInfo", report.BenchmarkCase.DisplayInfo },

0 commit comments

Comments
 (0)