2021-01-05 04:21:50 +08:00
|
|
|
|
2020-09-02 22:43:28 +08:00
|
|
|
#pragma once
|
|
|
|
|
2021-01-05 04:21:50 +08:00
|
|
|
#include "json_benchmark/file_runner.h"
|
|
|
|
#include "tweet.h"
|
|
|
|
#include <vector>
|
2020-09-02 22:43:28 +08:00
|
|
|
|
|
|
|
namespace partial_tweets {
|
|
|
|
|
2021-01-07 11:58:38 +08:00
|
|
|
using namespace json_benchmark;
|
|
|
|
|
2021-01-05 04:21:50 +08:00
|
|
|
template<typename I>
|
2021-01-07 11:58:38 +08:00
|
|
|
struct runner : public file_runner<I> {
|
2021-01-07 06:38:12 +08:00
|
|
|
std::vector<tweet<typename I::StringType>> result{};
|
2020-09-02 22:43:28 +08:00
|
|
|
|
2021-01-05 04:21:50 +08:00
|
|
|
bool setup(benchmark::State &state) {
|
2021-01-07 11:58:38 +08:00
|
|
|
return this->load_json(state, TWITTER_JSON);
|
2021-01-05 04:21:50 +08:00
|
|
|
}
|
2020-09-02 22:43:28 +08:00
|
|
|
|
2021-01-05 04:21:50 +08:00
|
|
|
bool before_run(benchmark::State &state) {
|
2021-01-07 11:58:38 +08:00
|
|
|
if (!file_runner<I>::before_run(state)) { return false; }
|
2021-01-06 03:31:34 +08:00
|
|
|
result.clear();
|
2021-01-05 04:21:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool run(benchmark::State &) {
|
2021-01-06 03:31:34 +08:00
|
|
|
return this->implementation.run(this->json, result);
|
2021-01-05 04:21:50 +08:00
|
|
|
}
|
2020-09-02 22:43:28 +08:00
|
|
|
|
2021-01-05 04:21:50 +08:00
|
|
|
template<typename R>
|
|
|
|
bool diff(benchmark::State &state, runner<R> &reference) {
|
2021-01-07 11:58:38 +08:00
|
|
|
return diff_results(state, result, reference.result, diff_flags::NONE);
|
2020-09-02 22:43:28 +08:00
|
|
|
}
|
|
|
|
|
2021-01-05 04:21:50 +08:00
|
|
|
size_t items_per_iteration() {
|
2021-01-06 03:31:34 +08:00
|
|
|
return result.size();
|
2021-01-05 04:21:50 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct simdjson_dom;
|
|
|
|
|
|
|
|
template<typename I> simdjson_really_inline static void partial_tweets(benchmark::State &state) {
|
2021-01-07 11:58:38 +08:00
|
|
|
run_json_benchmark<runner<I>, runner<simdjson_dom>>(state);
|
2020-09-02 22:43:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace partial_tweets
|