| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // DuckDB |
| 4 | // |
| 5 | // benchmark_runner.hpp |
| 6 | // |
| 7 | // Author: Mark Raasveldt |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #pragma once |
| 12 | |
| 13 | #include "benchmark.hpp" |
| 14 | #include "duckdb/common/constants.hpp" |
| 15 | #include "duckdb/common/fstream.hpp" |
| 16 | |
| 17 | namespace duckdb { |
| 18 | class DuckDB; |
| 19 | |
| 20 | //! The benchmark runner class is responsible for running benchmarks |
| 21 | class BenchmarkRunner { |
| 22 | BenchmarkRunner() { |
| 23 | } |
| 24 | |
| 25 | public: |
| 26 | static constexpr const char *DUCKDB_BENCHMARK_DIRECTORY = "duckdb_benchmark_data" ; |
| 27 | |
| 28 | static BenchmarkRunner &GetInstance() { |
| 29 | static BenchmarkRunner instance; |
| 30 | return instance; |
| 31 | } |
| 32 | |
| 33 | //! Save the current database state, exporting it to a set of CSVs in the DUCKDB_BENCHMARK_DIRECTORY directory |
| 34 | static void SaveDatabase(DuckDB &db, string name); |
| 35 | //! Try to initialize the database from the DUCKDB_BENCHMARK_DIRECTORY |
| 36 | static bool TryLoadDatabase(DuckDB &db, string name); |
| 37 | |
| 38 | //! Register a benchmark in the Benchmark Runner, this is done automatically |
| 39 | //! as long as the proper macro's are used |
| 40 | static void RegisterBenchmark(Benchmark *benchmark); |
| 41 | |
| 42 | void Log(string message); |
| 43 | void LogLine(string message); |
| 44 | void LogResult(string message); |
| 45 | void LogOutput(string message); |
| 46 | |
| 47 | void RunBenchmark(Benchmark *benchmark); |
| 48 | void RunBenchmarks(); |
| 49 | |
| 50 | vector<Benchmark *> benchmarks; |
| 51 | ofstream out_file; |
| 52 | ofstream log_file; |
| 53 | }; |
| 54 | |
| 55 | } // namespace duckdb |
| 56 | |