MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / BM_SimpleTableReaderAsyncMulti

Function BM_SimpleTableReaderAsyncMulti

src/sdk/mini_cluster_microbenchmark.cc:136–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134 return true;
135}
136static 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
176static void BM_SimpleTableReaderAsync(benchmark::State& state) { // NOLINT
177 ::fedb::sdk::SQLRouterOptions sql_opt;

Callers

nothing calls this directly

Calls 13

NewClusterSQLRouterFunction · 0.85
to_stringFunction · 0.85
Async3TimesFunction · 0.85
GetZkClusterMethod · 0.80
GetZkPathMethod · 0.80
ExecuteDDLMethod · 0.80
ExecuteInsertMethod · 0.80
GetTableReaderMethod · 0.80
GenRandFunction · 0.70
CreateDBMethod · 0.45
RefreshCatalogMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected