| 1 | #include "benchmark_runner.hpp" |
| 2 | #include "compare_result.hpp" |
| 3 | #include "dbgen.hpp" |
| 4 | #include "duckdb_benchmark_macro.hpp" |
| 5 | |
| 6 | using namespace duckdb; |
| 7 | using namespace std; |
| 8 | |
| 9 | #define SF 2 |
| 10 | |
| 11 | //----------------------------- SUFFIX ---------------------------------------- |
| 12 | DUCKDB_BENCHMARK(SuffixLineitemShort, "[suffix_tpch]" ) |
| 13 | void Load(DuckDBBenchmarkState *state) override { |
| 14 | // load the data into the tpch schema |
| 15 | tpch::dbgen(SF, state->db); |
| 16 | } |
| 17 | string GetQuery() override { // 25% of TPC-H SF 1 |
| 18 | return "SELECT l_shipinstruct FROM lineitem WHERE suffix(l_shipinstruct, 'NONE')" ; |
| 19 | } |
| 20 | string VerifyResult(QueryResult *result) override { |
| 21 | if (!result->success) { |
| 22 | return result->error; |
| 23 | } |
| 24 | return string(); |
| 25 | } |
| 26 | string BenchmarkInfo() override { |
| 27 | return "Short Suffix LineItem" ; |
| 28 | } |
| 29 | FINISH_BENCHMARK(SuffixLineitemShort) |
| 30 | |
| 31 | DUCKDB_BENCHMARK(SuffixLineitemMedium, "[suffix_tpch]" ) |
| 32 | void Load(DuckDBBenchmarkState *state) override { |
| 33 | // load the data into the tpch schema |
| 34 | tpch::dbgen(SF, state->db); |
| 35 | } |
| 36 | string GetQuery() override { // 25% of TPC-H SF 1 |
| 37 | return "SELECT l_shipinstruct FROM lineitem WHERE suffix(l_shipinstruct, 'CK RETURN')" ; |
| 38 | } |
| 39 | string VerifyResult(QueryResult *result) override { |
| 40 | if (!result->success) { |
| 41 | return result->error; |
| 42 | } |
| 43 | return string(); |
| 44 | } |
| 45 | string BenchmarkInfo() override { |
| 46 | return "Medium Suffix LineItem" ; |
| 47 | } |
| 48 | FINISH_BENCHMARK(SuffixLineitemMedium) |
| 49 | |
| 50 | DUCKDB_BENCHMARK(SuffixLineitemLong, "[suffix_tpch]" ) |
| 51 | void Load(DuckDBBenchmarkState *state) override { |
| 52 | // load the data into the tpch schema |
| 53 | tpch::dbgen(SF, state->db); |
| 54 | } |
| 55 | string GetQuery() override { // 25% of TPC-H SF 1 |
| 56 | return "SELECT l_shipinstruct FROM lineitem WHERE suffix(l_shipinstruct, 'LIVER IN PERSON')" ; |
| 57 | } |
| 58 | string VerifyResult(QueryResult *result) override { |
| 59 | if (!result->success) { |
| 60 | return result->error; |
| 61 | } |
| 62 | return string(); |
| 63 | } |
| 64 | string BenchmarkInfo() override { |
| 65 | return "Long Suffix LineItem" ; |
| 66 | } |
| 67 | FINISH_BENCHMARK(SuffixLineitemLong) |
| 68 | |
| 69 | //-------------------------------- LIKE --------------------------------------- |
| 70 | DUCKDB_BENCHMARK(SuffixLineitemLikeShort, "[suffix_tpch]" ) |
| 71 | void Load(DuckDBBenchmarkState *state) override { |
| 72 | // load the data into the tpch schema |
| 73 | tpch::dbgen(SF, state->db); |
| 74 | } |
| 75 | string GetQuery() override { |
| 76 | return "SELECT l_shipinstruct FROM lineitem WHERE l_shipinstruct LIKE '%NONE'" ; |
| 77 | } |
| 78 | string VerifyResult(QueryResult *result) override { |
| 79 | if (!result->success) { |
| 80 | return result->error; |
| 81 | } |
| 82 | return string(); |
| 83 | } |
| 84 | string BenchmarkInfo() override { |
| 85 | return "Short Suffix LineItem LIKE" ; |
| 86 | } |
| 87 | FINISH_BENCHMARK(SuffixLineitemLikeShort) |
| 88 | |
| 89 | DUCKDB_BENCHMARK(SuffixLineitemLikeMedium, "[suffix_tpch]" ) |
| 90 | void Load(DuckDBBenchmarkState *state) override { |
| 91 | // load the data into the tpch schema |
| 92 | tpch::dbgen(SF, state->db); |
| 93 | } |
| 94 | string GetQuery() override { |
| 95 | return "SELECT l_shipinstruct FROM lineitem WHERE l_shipinstruct LIKE '%CK RETURN'" ; |
| 96 | } |
| 97 | string VerifyResult(QueryResult *result) override { |
| 98 | if (!result->success) { |
| 99 | return result->error; |
| 100 | } |
| 101 | return string(); |
| 102 | } |
| 103 | string BenchmarkInfo() override { |
| 104 | return "Medium Suffix LineItem LIKE" ; |
| 105 | } |
| 106 | FINISH_BENCHMARK(SuffixLineitemLikeMedium) |
| 107 | |
| 108 | DUCKDB_BENCHMARK(SuffixLineitemLikeLong, "[suffix_tpch]" ) |
| 109 | void Load(DuckDBBenchmarkState *state) override { |
| 110 | // load the data into the tpch schema |
| 111 | tpch::dbgen(SF, state->db); |
| 112 | } |
| 113 | string GetQuery() override { |
| 114 | return "SELECT l_shipinstruct FROM lineitem WHERE l_shipinstruct LIKE '%LIVER IN PERSON'" ; |
| 115 | } |
| 116 | string VerifyResult(QueryResult *result) override { |
| 117 | if (!result->success) { |
| 118 | return result->error; |
| 119 | } |
| 120 | return string(); |
| 121 | } |
| 122 | string BenchmarkInfo() override { |
| 123 | return "LongSuffix LineItem LIKE" ; |
| 124 | } |
| 125 | FINISH_BENCHMARK(SuffixLineitemLikeLong) |
| 126 | |