simdjson/benchmark/find_tweet/simdjson_dom.h

33 lines
640 B
C
Raw Normal View History

#pragma once
#if SIMDJSON_EXCEPTIONS
#include "find_tweet.h"
namespace find_tweet {
using namespace simdjson;
struct simdjson_dom {
2021-01-07 06:38:12 +08:00
using StringType=std::string_view;
dom::parser parser{};
2021-01-06 03:31:34 +08:00
bool run(simdjson::padded_string &json, uint64_t find_id, std::string_view &result) {
result = "";
auto doc = parser.parse(json);
for (auto tweet : doc["statuses"]) {
if (uint64_t(tweet["id"]) == find_id) {
2021-01-06 03:31:34 +08:00
result = tweet["text"];
return true;
}
}
return false;
}
};
2021-01-06 02:45:49 +08:00
BENCHMARK_TEMPLATE(find_tweet, simdjson_dom)->UseManualTime();
} // namespace find_tweet
#endif // SIMDJSON_EXCEPTIONS