File tree Expand file tree Collapse file tree 1 file changed +117
-1
lines changed Expand file tree Collapse file tree 1 file changed +117
-1
lines changed Original file line number Diff line number Diff line change 11#include < benchmark/benchmark.h>
22
3- #include < cassert> // assert
3+ #include < algorithm> // std::ranges
4+ #include < cassert> // assert
45
56#include < sourcemeta/core/json.h>
67
@@ -92,6 +93,120 @@ static void JSON_Parse_1(benchmark::State &state) {
9293 }
9394}
9495
96+ static void JSON_Parse_Real (benchmark::State &state) {
97+ const auto document{R"JSON( [
98+ 1.0,
99+ 2.0,
100+ 3.5,
101+ 4.25,
102+ 5.125,
103+ 6.0625,
104+ 7.5,
105+ 8.75,
106+ 9.375,
107+ 10.5,
108+ 0.5,
109+ 0.25,
110+ 0.125,
111+ 0.0625,
112+ 0.03125,
113+ 1024.0,
114+ 2048.5,
115+ 4096.25,
116+ 8192.125,
117+ 16384.0625,
118+ -1.0,
119+ -2.5,
120+ -3.25,
121+ -4.125,
122+ -5.0625,
123+ 100.5,
124+ 200.25,
125+ 300.125,
126+ 400.0625,
127+ 500.03125,
128+ 1.0,
129+ 2.0,
130+ 3.5,
131+ 4.25,
132+ 5.125,
133+ 6.0625,
134+ 7.5,
135+ 8.75,
136+ 9.375,
137+ 10.5,
138+ 0.5,
139+ 0.25,
140+ 0.125,
141+ 0.0625,
142+ 0.03125,
143+ 1024.0,
144+ 2048.5,
145+ 4096.25,
146+ 8192.125,
147+ 16384.0625,
148+ -1.0,
149+ -2.5,
150+ -3.25,
151+ -4.125,
152+ -5.0625,
153+ 100.5,
154+ 200.25,
155+ 300.125,
156+ 400.0625,
157+ 500.03125,
158+ 1.0,
159+ 2.0,
160+ 3.5,
161+ 4.25,
162+ 5.125,
163+ 6.0625,
164+ 7.5,
165+ 8.75,
166+ 9.375,
167+ 10.5,
168+ 0.5,
169+ 0.25,
170+ 0.125,
171+ 0.0625,
172+ 0.03125,
173+ 1024.0,
174+ 2048.5,
175+ 4096.25,
176+ 8192.125,
177+ 16384.0625,
178+ -1.0,
179+ -2.5,
180+ -3.25,
181+ -4.125,
182+ -5.0625,
183+ 100.5,
184+ 200.25,
185+ 300.125,
186+ 400.0625,
187+ 500.03125,
188+ 1.0,
189+ 2.0,
190+ 3.5,
191+ 4.25,
192+ 5.125,
193+ 6.0625,
194+ 7.5,
195+ 8.75,
196+ 9.375,
197+ 10.5
198+ ])JSON" };
199+
200+ assert (std::ranges::all_of (sourcemeta::core::parse_json (document).as_array (),
201+ [](const auto &item) { return item.is_real (); }));
202+
203+ for (auto _ : state) {
204+ auto result{sourcemeta::core::parse_json (document)};
205+ assert (result.is_array ());
206+ benchmark::DoNotOptimize (result);
207+ }
208+ }
209+
95210static void JSON_Fast_Hash_Helm_Chart_Lock (benchmark::State &state) {
96211 // From `helm-chart-lock`
97212 const auto document{sourcemeta::core::parse_json (R"JSON( {
@@ -311,6 +426,7 @@ static void JSON_Object_Defines_Miss_Too_Large(benchmark::State &state) {
311426
312427BENCHMARK (JSON_Array_Of_Objects_Unique);
313428BENCHMARK (JSON_Parse_1);
429+ BENCHMARK (JSON_Parse_Real);
314430BENCHMARK (JSON_Fast_Hash_Helm_Chart_Lock);
315431BENCHMARK (JSON_Equality_Helm_Chart_Lock);
316432BENCHMARK (JSON_String_Equal)->Args({10 })->Args({100 });
You can’t perform that action at this time.
0 commit comments