1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // DuckDB |
4 | // |
5 | // duckdb_benchmark_macro.hpp |
6 | // |
7 | // Author: Mark Raasveldt |
8 | // |
9 | //===----------------------------------------------------------------------===// |
10 | |
11 | #pragma once |
12 | |
13 | #include "duckdb_benchmark.hpp" |
14 | #include "sqlite_benchmark.hpp" |
15 | |
16 | #define DUCKDB_BENCHMARK(NAME, GROUP) \ |
17 | class NAME##Benchmark : public DuckDBBenchmark { \ |
18 | NAME##Benchmark(bool register_benchmark) : DuckDBBenchmark(register_benchmark, "" #NAME, GROUP) { \ |
19 | } \ |
20 | \ |
21 | public: \ |
22 | static NAME##Benchmark *GetInstance() { \ |
23 | static NAME##Benchmark singleton(true); \ |
24 | auto benchmark = unique_ptr<DuckDBBenchmark>(new NAME##Benchmark(false)); \ |
25 | if (!benchmark->GetQuery().empty()) { \ |
26 | static SQLiteBenchmark sqlite_singleton(move(benchmark)); \ |
27 | } \ |
28 | return &singleton; \ |
29 | } |
30 | |
31 | #define REGISTER_BENCHMARK(NAME) auto global_instance_##NAME = NAME##Benchmark::GetInstance() |
32 | |
33 | #define FINISH_BENCHMARK(NAME) \ |
34 | } \ |
35 | ; \ |
36 | REGISTER_BENCHMARK(NAME); |
37 | |
38 | namespace duckdb {} |
39 | |