1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // |
3 | // DuckDB |
4 | // |
5 | // sqlite_benchmark.hpp |
6 | // |
7 | // Author: Mark Raasveldt |
8 | // |
9 | //===----------------------------------------------------------------------===// |
10 | |
11 | #pragma once |
12 | |
13 | #include "duckdb_benchmark.hpp" |
14 | #include "sqlite3.h" |
15 | |
16 | namespace duckdb { |
17 | |
18 | struct SQLiteBenchmarkState : public BenchmarkState { |
19 | //! The result object of the query |
20 | unique_ptr<QueryResult> result; |
21 | //! The SQLite Database Object |
22 | sqlite3 *db = nullptr; |
23 | //! Flag used to interrupt query execution. Set to 1 to interrupt query. |
24 | volatile int interrupt = 0; |
25 | //! The result types |
26 | vector<SQLType> types; |
27 | |
28 | SQLiteBenchmarkState() : db(nullptr), interrupt(0) { |
29 | } |
30 | virtual ~SQLiteBenchmarkState() { |
31 | if (db) { |
32 | sqlite3_close(db); |
33 | } |
34 | } |
35 | }; |
36 | |
37 | class SQLiteBenchmark : public Benchmark { |
38 | public: |
39 | SQLiteBenchmark(unique_ptr<DuckDBBenchmark> duckdb); |
40 | |
41 | unique_ptr<BenchmarkState> Initialize() override; |
42 | void Run(BenchmarkState *state_) override; |
43 | void Cleanup(BenchmarkState *state_) override; |
44 | string Verify(BenchmarkState *state_) override; |
45 | string GetLogOutput(BenchmarkState *state_) override; |
46 | void Interrupt(BenchmarkState *state_) override; |
47 | string BenchmarkInfo() override; |
48 | |
49 | private: |
50 | unique_ptr<DuckDBBenchmark> duckdb_benchmark; |
51 | }; |
52 | |
53 | } // namespace duckdb |
54 |