MCPcopy Create free account
hub / github.com/ElementsProject/elements / BM_LogAndApply

Function BM_LogAndApply

src/leveldb/db/db_test.cc:2238–2288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2236}
2237
2238void BM_LogAndApply(int iters, int num_base_files) {
2239 std::string dbname = test::TmpDir() + "/leveldb_test_benchmark";
2240 DestroyDB(dbname, Options());
2241
2242 DB* db = nullptr;
2243 Options opts;
2244 opts.create_if_missing = true;
2245 Status s = DB::Open(opts, dbname, &db);
2246 ASSERT_OK(s);
2247 ASSERT_TRUE(db != nullptr);
2248
2249 delete db;
2250 db = nullptr;
2251
2252 Env* env = Env::Default();
2253
2254 port::Mutex mu;
2255 MutexLock l(&mu);
2256
2257 InternalKeyComparator cmp(BytewiseComparator());
2258 Options options;
2259 VersionSet vset(dbname, &options, nullptr, &cmp);
2260 bool save_manifest;
2261 ASSERT_OK(vset.Recover(&save_manifest));
2262 VersionEdit vbase;
2263 uint64_t fnum = 1;
2264 for (int i = 0; i < num_base_files; i++) {
2265 InternalKey start(MakeKey(2 * fnum), 1, kTypeValue);
2266 InternalKey limit(MakeKey(2 * fnum + 1), 1, kTypeDeletion);
2267 vbase.AddFile(2, fnum++, 1 /* file size */, start, limit);
2268 }
2269 ASSERT_OK(vset.LogAndApply(&vbase, &mu));
2270
2271 uint64_t start_micros = env->NowMicros();
2272
2273 for (int i = 0; i < iters; i++) {
2274 VersionEdit vedit;
2275 vedit.DeleteFile(2, fnum);
2276 InternalKey start(MakeKey(2 * fnum), 1, kTypeValue);
2277 InternalKey limit(MakeKey(2 * fnum + 1), 1, kTypeDeletion);
2278 vedit.AddFile(2, fnum++, 1 /* file size */, start, limit);
2279 vset.LogAndApply(&vedit, &mu);
2280 }
2281 uint64_t stop_micros = env->NowMicros();
2282 unsigned int us = stop_micros - start_micros;
2283 char buf[16];
2284 snprintf(buf, sizeof(buf), "%d", num_base_files);
2285 fprintf(stderr,
2286 "BM_LogAndApply/%-6s %8d iters : %9u us (%7.0f us / iter)\n", buf,
2287 iters, us, ((float)us) / iters);
2288}
2289
2290} // namespace leveldb
2291

Callers 1

mainFunction · 0.85

Calls 10

TmpDirFunction · 0.85
DestroyDBFunction · 0.85
BytewiseComparatorFunction · 0.85
MakeKeyFunction · 0.85
AddFileMethod · 0.80
LogAndApplyMethod · 0.80
OptionsClass · 0.70
RecoverMethod · 0.45
NowMicrosMethod · 0.45
DeleteFileMethod · 0.45

Tested by

no test coverage detected