| 5337 | } |
| 5338 | |
| 5339 | static void json_simdjson_ondemand(bm::State &state) { |
| 5340 | std::size_t bytes_processed = 0; |
| 5341 | std::size_t iteration = 0; |
| 5342 | |
| 5343 | // Pre-allocate padded strings outside the hot path |
| 5344 | simdjson::padded_string padded_strings[3] = { |
| 5345 | simdjson::padded_string(packets_json[0]), |
| 5346 | simdjson::padded_string(packets_json[1]), |
| 5347 | simdjson::padded_string(packets_json[2]), |
| 5348 | }; |
| 5349 | |
| 5350 | // On-demand parser reuses internal buffers |
| 5351 | simdjson::ondemand::parser parser; |
| 5352 | simdjson::ondemand::document doc; |
| 5353 | |
| 5354 | for (auto _ : state) { |
| 5355 | std::size_t const packet_index = iteration++ % 3; |
| 5356 | bytes_processed += packets_json[packet_index].size(); |
| 5357 | |
| 5358 | auto error = parser.iterate(padded_strings[packet_index]).get(doc); |
| 5359 | if (error == simdjson::SUCCESS) { |
| 5360 | simdjson::ondemand::value root; |
| 5361 | if (doc.get_value().get(root) == simdjson::SUCCESS) |
| 5362 | bm::DoNotOptimize(contains_xss_in_simdjson_ondemand(root)); |
| 5363 | } |
| 5364 | } |
| 5365 | |
| 5366 | state.SetBytesProcessed(bytes_processed); |
| 5367 | } |
| 5368 | |
| 5369 | static void json_simdjson_dom(bm::State &state) { |
| 5370 | std::size_t bytes_processed = 0; |
nothing calls this directly
no test coverage detected