| 134 | return true; |
| 135 | } |
| 136 | static void BM_SimpleTableReaderAsyncMulti(benchmark::State& state) { // NOLINT |
| 137 | ::fedb::sdk::SQLRouterOptions sql_opt; |
| 138 | sql_opt.zk_cluster = mc->GetZkCluster(); |
| 139 | sql_opt.zk_path = mc->GetZkPath(); |
| 140 | auto router = NewClusterSQLRouter(sql_opt); |
| 141 | if (router == nullptr) { |
| 142 | std::cout << "fail to init sql cluster router" << std::endl; |
| 143 | return; |
| 144 | } |
| 145 | std::string db = "db" + GenRand(); |
| 146 | ::hybridse::sdk::Status status; |
| 147 | router->CreateDB(db, &status); |
| 148 | std::string ddl = |
| 149 | "create table t1" |
| 150 | "(" |
| 151 | "col1 string, col2 bigint," |
| 152 | "index(key=col1, ts=col2));"; |
| 153 | router->ExecuteDDL(db, ddl, &status); |
| 154 | router->RefreshCatalog(); |
| 155 | int64_t st = 361; |
| 156 | int64_t et = 1; |
| 157 | int records = state.range(0); |
| 158 | std::string key = "k1"; |
| 159 | for (int32_t i = 1; i < records + 361; i++) { |
| 160 | std::string row = "insert into t1 values('" + key + "', " + std::to_string(i) + "L);"; |
| 161 | router->ExecuteInsert(db, row, &status); |
| 162 | } |
| 163 | auto reader = router->GetTableReader(); |
| 164 | |
| 165 | ::fedb::sdk::ScanOption so; |
| 166 | auto rs = reader->Scan(db, "t1", key, st, et, so, &status); |
| 167 | if (!rs || rs->Size() < 300) { |
| 168 | LOG(WARNING) << "result count is mismatch"; |
| 169 | return; |
| 170 | } |
| 171 | for (auto _ : state) { |
| 172 | benchmark::DoNotOptimize(Async3Times(db, "t1", key, st, et, reader, &status)); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | static void BM_SimpleTableReaderAsync(benchmark::State& state) { // NOLINT |
| 177 | ::fedb::sdk::SQLRouterOptions sql_opt; |
nothing calls this directly
no test coverage detected