Skip to content

Commit 8023ecc

Browse files
Updated benchmark, moved PathSelect to JsonPathSelect. Updated read.me with benchmark data
1 parent 78bd307 commit 8023ecc

9 files changed

+540
-334
lines changed

README.md

Lines changed: 201 additions & 36 deletions
Large diffs are not rendered by default.

test/Hyperbee.Json.Benchmark/Config.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public Config()
2424
);
2525

2626
// Customize the summary style to prevent truncation
27-
WithSummaryStyle( SummaryStyle.Default.WithMaxParameterColumnWidth( 50 ) );
27+
WithSummaryStyle( SummaryStyle.Default.WithMaxParameterColumnWidth( 100 ) );
2828

2929
// Add the custom exporter with specified visible columns
3030
AddExporter( new JsonPathMarkdownExporter

test/Hyperbee.Json.Benchmark/JsonPathParseAndSelectEvaluator.cs

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ namespace Hyperbee.Json.Benchmark;
1212

1313
public class JsonPathParseAndSelectEvaluator
1414
{
15-
//[Params(
16-
// "$.store.book[0]",
17-
// "$.store.book[?(@.price == 8.99)]",
18-
// "$..price",
19-
// "$..* ::First()",
20-
// "$..*"
21-
//)]
2215
[Params(
2316
"$.store.book[0].title",
2417
"$.store.book[*].author",
@@ -36,11 +29,23 @@ public class JsonPathParseAndSelectEvaluator
3629
"$..['bicycle','price']",
3730
"$..[?(@.price < 10)]",
3831
"$.store.book[?(@.author && @.title)]",
39-
"$.store.*"
32+
"$.store.*",
33+
"$",
34+
"$.store.book[0]",
35+
"$..book[0]",
36+
"$.store.book[0,1]",
37+
"$.store.book['category','author']",
38+
"$..book[?@.isbn]",
39+
"$.store.book[?@.price == 8.99]",
40+
"$..book[?@.price == 8.99 && @.category == 'fiction']"
4041
)]
4142
public string Filter;
4243

4344
public string Document;
45+
public JsonNode _node;
46+
public JsonElement _element;
47+
private JObject _jObject;
48+
4449

4550
public Consumer _consumer = new();
4651

@@ -86,6 +91,11 @@ public void Setup()
8691
}
8792
}
8893
""";
94+
95+
96+
_jObject = JObject.Parse( Document );
97+
_node = JsonNode.Parse( Document )!;
98+
_element = JsonDocument.Parse( Document ).RootElement;
8999
}
90100

91101
public (string, bool) GetFilter()
@@ -116,51 +126,51 @@ public void Hyperbee_JsonElement()
116126
Consume( select, first );
117127
}
118128

119-
//[Benchmark( Description = "Hyperbee.JsonNode" )]
120-
//public void Hyperbee_JsonNode()
121-
//{
122-
// var (filter, first) = GetFilter();
129+
[Benchmark( Description = "Hyperbee.JsonNode" )]
130+
public void Hyperbee_JsonNode()
131+
{
132+
var (filter, first) = GetFilter();
123133

124-
// var node = JsonNode.Parse( Document )!;
125-
// var select = node.Select( filter );
134+
var node = JsonNode.Parse( Document )!;
135+
var select = node.Select( filter );
126136

127-
// Consume( select, first );
128-
//}
137+
Consume( select, first );
138+
}
129139

130-
//[Benchmark( Description = "Newtonsoft.JObject" )]
131-
//public void Newtonsoft_JObject()
132-
//{
133-
// var (filter, first) = GetFilter();
140+
[Benchmark( Description = "Newtonsoft.JObject" )]
141+
public void Newtonsoft_JObject()
142+
{
143+
var (filter, first) = GetFilter();
134144

135-
// var jObject = JObject.Parse( Document );
136-
// var select = jObject.SelectTokens( filter );
145+
var jObject = JObject.Parse( Document );
146+
var select = jObject.SelectTokens( filter );
137147

138-
// Consume( select, first );
139-
//}
148+
Consume( select, first );
149+
}
140150

141-
//[Benchmark( Description = "JsonEverything.JsonNode" )]
142-
//public void JsonEverything_JsonNode()
143-
//{
144-
// var (filter, first) = GetFilter();
151+
[Benchmark( Description = "JsonEverything.JsonNode" )]
152+
public void JsonEverything_JsonNode()
153+
{
154+
var (filter, first) = GetFilter();
145155

146-
// var path = JsonEverything.JsonPath.Parse( filter );
147-
// var node = JsonNode.Parse( Document )!;
148-
// var select = path.Evaluate( node ).Matches!;
156+
var path = JsonEverything.JsonPath.Parse( filter );
157+
var node = JsonNode.Parse( Document )!;
158+
var select = path.Evaluate( node ).Matches!;
149159

150-
// Consume( select, first );
151-
//}
160+
Consume( select, first );
161+
}
152162

153-
//[Benchmark( Description = "JsonCons.JsonElement" )]
154-
//public void JsonCons_JsonElement()
155-
//{
156-
// var (filter, first) = GetFilter();
163+
[Benchmark( Description = "JsonCons.JsonElement" )]
164+
public void JsonCons_JsonElement()
165+
{
166+
var (filter, first) = GetFilter();
157167

158-
// var path = JsonSelector.Parse( filter )!;
159-
// var element = JsonDocument.Parse( Document ).RootElement;
160-
// var select = path.Select( element );
168+
var path = JsonSelector.Parse( filter )!;
169+
var element = JsonDocument.Parse( Document ).RootElement;
170+
var select = path.Select( element );
161171

162-
// Consume( select, first );
163-
//}
172+
Consume( select, first );
173+
}
164174

165175
[Benchmark( Description = "JsonCraft.JsonElement" )]
166176
public void JsonCraft_JsonElement()

test/Hyperbee.Json.Benchmark/JsonPathSelectEvaluator.cs

Lines changed: 0 additions & 109 deletions
This file was deleted.

test/Hyperbee.Json.Benchmark/benchmark/results/Hyperbee.Json.Benchmark.FilterExpressionParserEvaluator-report-jsonpath.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
```
22
3-
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.4061)
4-
Intel Core i9-9980HK CPU 2.40GHz, 1 CPU, 16 logical and 8 physical cores
5-
.NET SDK 9.0.203
6-
[Host] : .NET 9.0.4 (9.0.425.16305), X64 RyuJIT AVX2
7-
ShortRun : .NET 9.0.4 (9.0.425.16305), X64 RyuJIT AVX2
3+
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.4351)
4+
12th Gen Intel Core i9-12900HK, 1 CPU, 20 logical and 14 physical cores
5+
.NET SDK 9.0.301
6+
[Host] : .NET 9.0.6 (9.0.625.26613), X64 RyuJIT AVX2 [AttachedDebugger]
7+
ShortRun : .NET 9.0.6 (9.0.625.26613), X64 RyuJIT AVX2
88
99
1010
| Method | Mean | Error
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
```
22
3-
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.4061)
4-
Intel Core i9-9980HK CPU 2.40GHz, 1 CPU, 16 logical and 8 physical cores
5-
.NET SDK 9.0.203
6-
[Host] : .NET 9.0.4 (9.0.425.16305), X64 RyuJIT AVX2
7-
ShortRun : .NET 9.0.4 (9.0.425.16305), X64 RyuJIT AVX2
3+
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.4351)
4+
12th Gen Intel Core i9-12900HK, 1 CPU, 20 logical and 14 physical cores
5+
.NET SDK 9.0.301
6+
[Host] : .NET 9.0.6 (9.0.625.26613), X64 RyuJIT AVX2 [AttachedDebugger]
7+
ShortRun : .NET 9.0.6 (9.0.625.26613), X64 RyuJIT AVX2
88
99
10-
| Method | Mean | Error | StdDev | Allocated
11-
| :-------------------- | ----------: | ----------: | ---------: | ---------:
12-
| JsonDiff_JsonNode | 778.8 ns | 703.7 ns | 38.57 ns | 1.2 KB
13-
| JsonDiff_JsonElement | 1,370.3 ns | 5,661.7 ns | 310.33 ns | 1.66 KB
14-
| | | | |
15-
| JsonDiff_JsonNode | 1,013.3 ns | 781.3 ns | 42.82 ns | 1.3 KB
16-
| JsonDiff_JsonElement | 1,304.2 ns | 347.2 ns | 19.03 ns | 1.93 KB
10+
| Method | Mean | Error | StdDev | Allocated
11+
| :-------------------- | --------: | ---------: | --------: | ---------:
12+
| JsonDiff_JsonNode | 572.1 ns | 164.76 ns | 9.03 ns | 1.2 KB
13+
| JsonDiff_JsonElement | 704.5 ns | 219.53 ns | 12.03 ns | 1.66 KB
14+
| | | | |
15+
| JsonDiff_JsonNode | 704.4 ns | 267.47 ns | 14.66 ns | 1.3 KB
16+
| JsonDiff_JsonElement | 905.6 ns | 73.54 ns | 4.03 ns | 1.93 KB
1717
```
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
```
22
3-
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.4061)
4-
Intel Core i9-9980HK CPU 2.40GHz, 1 CPU, 16 logical and 8 physical cores
5-
.NET SDK 9.0.203
6-
[Host] : .NET 9.0.4 (9.0.425.16305), X64 RyuJIT AVX2
7-
ShortRun : .NET 9.0.4 (9.0.425.16305), X64 RyuJIT AVX2
3+
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.4351)
4+
12th Gen Intel Core i9-12900HK, 1 CPU, 20 logical and 14 physical cores
5+
.NET SDK 9.0.301
6+
[Host] : .NET 9.0.6 (9.0.625.26613), X64 RyuJIT AVX2 [AttachedDebugger]
7+
ShortRun : .NET 9.0.6 (9.0.625.26613), X64 RyuJIT AVX2
88
99
10-
| Method | Mean | Error | StdDev | Allocated
11-
| :----------------------- | --------: | ---------: | --------: | ---------:
12-
| Hyperbee_JsonElement | 240.7 ns | 95.55 ns | 5.24 ns | 616 B
13-
| Hyperbee_JsonNode | 265.3 ns | 430.49 ns | 23.60 ns | 616 B
14-
| JsonEverything_JsonNode | 444.3 ns | 246.87 ns | 13.53 ns | 968 B
15-
| AspNetCore_JsonNode | 743.4 ns | 801.29 ns | 43.92 ns | 1024 B
10+
| Method | Mean | Error | StdDev | Allocated
11+
| :----------------------- | --------: | ---------: | -------: | ---------:
12+
| Hyperbee_JsonNode | 172.9 ns | 44.86 ns | 2.46 ns | 520 B
13+
| Hyperbee_JsonElement | 178.8 ns | 76.47 ns | 4.19 ns | 520 B
14+
| JsonEverything_JsonNode | 289.7 ns | 108.59 ns | 5.95 ns | 968 B
15+
| AspNetCore_JsonNode | 516.7 ns | 44.74 ns | 2.45 ns | 1024 B
1616
```

0 commit comments

Comments
 (0)