@@ -41,132 +41,6 @@ func execParserFunc(jsonPath, srcJSON string, b *testing.B) {
41
41
}
42
42
}
43
43
44
- // =====================================================================
45
- // Retrieve
46
-
47
- func BenchmarkRetrieve_dotNotation (b * testing.B ) {
48
- jsonPath := `$.a`
49
- srcJSON := `{"a":123.456}`
50
- execRetrieve (jsonPath , srcJSON , b )
51
- }
52
-
53
- func BenchmarkRetrieve_bracketNotation (b * testing.B ) {
54
- jsonPath := `$['a']`
55
- srcJSON := `{"a":123.456}`
56
- execRetrieve (jsonPath , srcJSON , b )
57
- }
58
-
59
- func BenchmarkRetrieve_wildcard_identifier_dotNotation (b * testing.B ) {
60
- jsonPath := `$.*`
61
- srcJSON := `{"a":123.456}`
62
- execRetrieve (jsonPath , srcJSON , b )
63
- }
64
-
65
- func BenchmarkRetrieve_wildcard_identifier_bracketNotation (b * testing.B ) {
66
- jsonPath := `$[*]`
67
- srcJSON := `{"a":123.456}`
68
- execRetrieve (jsonPath , srcJSON , b )
69
- }
70
-
71
- func BenchmarkRetrieve_multi_identifier (b * testing.B ) {
72
- jsonPath := `$['a','a']`
73
- srcJSON := `{"a":123.456}`
74
- execRetrieve (jsonPath , srcJSON , b )
75
- }
76
-
77
- func BenchmarkRetrieve_qualifier_index (b * testing.B ) {
78
- jsonPath := `$[0]`
79
- srcJSON := `[{"a":123.456}]`
80
- execRetrieve (jsonPath , srcJSON , b )
81
- }
82
-
83
- func BenchmarkRetrieve_qualifier_slice (b * testing.B ) {
84
- jsonPath := `$[0:1]`
85
- srcJSON := `[{"a":123.456}]`
86
- execRetrieve (jsonPath , srcJSON , b )
87
- }
88
-
89
- func BenchmarkRetrieve_qualifier_wildcard (b * testing.B ) {
90
- jsonPath := `$[*]`
91
- srcJSON := `[{"a":123.456}]`
92
- execRetrieve (jsonPath , srcJSON , b )
93
- }
94
-
95
- func BenchmarkRetrieve_qualifier_union (b * testing.B ) {
96
- jsonPath := `$[0,0]`
97
- srcJSON := `[{"a":123.456}]`
98
- execRetrieve (jsonPath , srcJSON , b )
99
- }
100
-
101
- func BenchmarkRetrieve_filter_logicalOR (b * testing.B ) {
102
- jsonPath := `$[?(@||@)]`
103
- srcJSON := `[{"a":1}]`
104
- execRetrieve (jsonPath , srcJSON , b )
105
- }
106
-
107
- func BenchmarkRetrieve_filter_logicalAND (b * testing.B ) {
108
- jsonPath := `$[?(@&&@)]`
109
- srcJSON := `[{"a":1}]`
110
- execRetrieve (jsonPath , srcJSON , b )
111
- }
112
-
113
- func BenchmarkRetrieve_filter_nodeFilter (b * testing.B ) {
114
- jsonPath := `$[?(@.a)]`
115
- srcJSON := `[{"a":1}]`
116
- execRetrieve (jsonPath , srcJSON , b )
117
- }
118
-
119
- func BenchmarkRetrieve_filter_logicalNOT (b * testing.B ) {
120
- jsonPath := `$[?(!@.a)]`
121
- srcJSON := `[{"a":1},{"b":1}]`
122
- execRetrieve (jsonPath , srcJSON , b )
123
- }
124
-
125
- func BenchmarkRetrieve_filter_compareEQ (b * testing.B ) {
126
- jsonPath := `$[?(@.a==1)]`
127
- srcJSON := `[{"a":1}]`
128
- execRetrieve (jsonPath , srcJSON , b )
129
- }
130
-
131
- func BenchmarkRetrieve_filter_compareNE (b * testing.B ) {
132
- jsonPath := `$[?(@.a!=2)]`
133
- srcJSON := `[{"a":1}]`
134
- execRetrieve (jsonPath , srcJSON , b )
135
- }
136
-
137
- func BenchmarkRetrieve_filter_compareGE (b * testing.B ) {
138
- jsonPath := `$[?(@.a<=2)]`
139
- srcJSON := `[{"a":1}]`
140
- execRetrieve (jsonPath , srcJSON , b )
141
- }
142
-
143
- func BenchmarkRetrieve_filter_compareGT (b * testing.B ) {
144
- jsonPath := `$[?(@.a<2)]`
145
- srcJSON := `[{"a":1}]`
146
- execRetrieve (jsonPath , srcJSON , b )
147
- }
148
-
149
- func BenchmarkRetrieve_filter_compareLE (b * testing.B ) {
150
- jsonPath := `$[?(@.a>=0)]`
151
- srcJSON := `[{"a":1}]`
152
- execRetrieve (jsonPath , srcJSON , b )
153
- }
154
-
155
- func BenchmarkRetrieve_filter_compareLT (b * testing.B ) {
156
- jsonPath := `$[?(@.a>0)]`
157
- srcJSON := `[{"a":1}]`
158
- execRetrieve (jsonPath , srcJSON , b )
159
- }
160
-
161
- func BenchmarkRetrieve_filter_regex (b * testing.B ) {
162
- jsonPath := `$[?(@.a =~ /ab/)]`
163
- srcJSON := `[{"a":"abc"}]`
164
- execRetrieve (jsonPath , srcJSON , b )
165
- }
166
-
167
- // =====================================================================
168
- // ParserFunc
169
-
170
44
func BenchmarkParserFunc_dotNotation (b * testing.B ) {
171
45
jsonPath := `$.a`
172
46
srcJSON := `{"a":123.456}`
@@ -286,3 +160,40 @@ func BenchmarkParserFunc_filter_regex(b *testing.B) {
286
160
srcJSON := `[{"a":"abc"}]`
287
161
execParserFunc (jsonPath , srcJSON , b )
288
162
}
163
+
164
+ func BenchmarkParserFunc_recursive (b * testing.B ) {
165
+ jsonPath := `$..price`
166
+ srcJSON := `{ "store": {
167
+ "book": [
168
+ { "category": "reference",
169
+ "author": "Nigel Rees",
170
+ "title": "Sayings of the Century",
171
+ "price": 8.95
172
+ },
173
+ { "category": "fiction",
174
+ "author": "Evelyn Waugh",
175
+ "title": "Sword of Honour",
176
+ "price": 12.99
177
+ },
178
+ { "category": "fiction",
179
+ "author": "Herman Melville",
180
+ "title": "Moby Dick",
181
+ "isbn": "0-553-21311-3",
182
+ "price": 8.99
183
+ },
184
+ { "category": "fiction",
185
+ "author": "J. R. R. Tolkien",
186
+ "title": "The Lord of the Rings",
187
+ "isbn": "0-395-19395-8",
188
+ "price": 22.99
189
+ }
190
+ ],
191
+ "bicycle": {
192
+ "color": "red",
193
+ "price": 19.95
194
+ }
195
+ }
196
+ }`
197
+
198
+ execParserFunc (jsonPath , srcJSON , b )
199
+ }
0 commit comments