2017-03-06 18:30:35 +01:00
|
|
|
#ifndef __BENCHMARK_UTILS_H__
|
|
|
|
#define __BENCHMARK_UTILS_H__
|
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
#include "benchmark/benchmark.h"
|
|
|
|
|
|
|
|
size_t getNumTokens(const std::string& query);
|
|
|
|
|
|
|
|
void BM_TokenizeBenchmark(benchmark::State& st, const std::string& query);
|
|
|
|
|
|
|
|
void BM_ParseBenchmark(benchmark::State& st, const std::string& query);
|
|
|
|
|
|
|
|
std::string readFileContents(const std::string& file_path);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-06 18:30:35 +01:00
|
|
|
|
|
|
|
#define TIME_DIFF(end, start)\
|
|
|
|
std::chrono::duration_cast<std::chrono::duration<double>>(end - start);
|
|
|
|
|
|
|
|
#define NOW()\
|
|
|
|
std::chrono::high_resolution_clock::now();
|
|
|
|
|
|
|
|
#define PARSE_QUERY_BENCHMARK(name, query)\
|
|
|
|
static void name(benchmark::State& st) {\
|
2017-07-21 02:47:45 +02:00
|
|
|
BM_ParseBenchmark(st, query);\
|
2017-03-06 18:30:35 +01:00
|
|
|
}\
|
|
|
|
BENCHMARK(name);
|
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
#define TOKENIZE_QUERY_BENCHMARK(name, query)\
|
|
|
|
static void name(benchmark::State& st) {\
|
|
|
|
BM_TokenizeBenchmark(st, query);\
|
|
|
|
}\
|
|
|
|
BENCHMARK(name);
|
|
|
|
|
|
|
|
|
|
|
|
#define BENCHMARK_QUERY(test_name, query)\
|
|
|
|
TOKENIZE_QUERY_BENCHMARK(test_name##Tokenize, query)\
|
|
|
|
PARSE_QUERY_BENCHMARK(test_name##Parse, query)
|
|
|
|
|
2017-03-06 18:30:35 +01:00
|
|
|
|
|
|
|
#endif
|