1 | #include "benchmark_runner.hpp" |
---|---|
2 | #include "duckdb_benchmark_macro.hpp" |
3 | #include "duckdb/main/appender.hpp" |
4 | |
5 | #include <random> |
6 | |
7 | using namespace duckdb; |
8 | using namespace std; |
9 | |
10 | #define RANGEJOIN_COUNT 100000 |
11 | |
12 | DUCKDB_BENCHMARK(RangeJoin, "[micro]") |
13 | virtual void Load(DuckDBBenchmarkState *state) { |
14 | // fixed seed random numbers |
15 | std::uniform_int_distribution<> distribution(1, 10000); |
16 | std::mt19937 gen; |
17 | gen.seed(42); |
18 | |
19 | state->conn.Query("CREATE TABLE integers(i INTEGER, j INTEGER);"); |
20 | Appender appender(state->conn, "integers"); // insert the elements into the database |
21 | for (size_t i = 0; i < RANGEJOIN_COUNT; i++) { |
22 | appender.BeginRow(); |
23 | appender.Append<int32_t>(distribution(gen)); |
24 | appender.Append<int32_t>(distribution(gen)); |
25 | appender.EndRow(); |
26 | } |
27 | } |
28 | |
29 | virtual string GetQuery() { |
30 | return "SELECT * FROM integers a, integers b WHERE (a.i / 1000) > b.j;"; |
31 | } |
32 | |
33 | virtual string VerifyResult(QueryResult *result) { |
34 | if (!result->success) { |
35 | return result->error; |
36 | } |
37 | return string(); |
38 | } |
39 | |
40 | virtual string BenchmarkInfo() { |
41 | return StringUtil::Format("Runs the following query: \"SELECT * FROM " |
42 | "integers a, integers b WHERE (a.i / 1000) > b.j;\"" |
43 | " on %d rows", |
44 | RANGEJOIN_COUNT); |
45 | } |
46 | FINISH_BENCHMARK(RangeJoin) |
47 |