2021-01-05 04:21:50 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#if SIMDJSON_EXCEPTIONS
|
|
|
|
|
|
|
|
#include "kostya.h"
|
|
|
|
|
|
|
|
namespace kostya {
|
|
|
|
|
|
|
|
using namespace simdjson;
|
|
|
|
|
2021-01-05 12:20:24 +08:00
|
|
|
struct simdjson_ondemand {
|
2021-01-07 11:58:38 +08:00
|
|
|
static constexpr diff_flags DiffFlags = diff_flags::NONE;
|
|
|
|
|
2021-01-05 04:21:50 +08:00
|
|
|
ondemand::parser parser{};
|
2021-01-05 12:20:24 +08:00
|
|
|
|
2021-01-06 03:31:34 +08:00
|
|
|
bool run(simdjson::padded_string &json, std::vector<point> &result) {
|
2021-01-05 04:21:50 +08:00
|
|
|
auto doc = parser.iterate(json);
|
|
|
|
for (ondemand::object point : doc.find_field("coordinates")) {
|
2021-01-07 11:58:38 +08:00
|
|
|
result.emplace_back(json_benchmark::point{point.find_field("x"), point.find_field("y"), point.find_field("z")});
|
2021-01-05 04:21:50 +08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-06 02:45:49 +08:00
|
|
|
BENCHMARK_TEMPLATE(kostya, simdjson_ondemand)->UseManualTime();
|
2021-01-05 04:21:50 +08:00
|
|
|
|
|
|
|
} // namespace kostya
|
|
|
|
|
|
|
|
#endif // SIMDJSON_EXCEPTIONS
|