Skip to content

Commit 77948e7

Browse files
ghemawatcmumford
authored andcommitted
Add benchmark that measures cost of repeatedly opening the database.
1 parent 34ad72e commit 77948e7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

db/db_bench.cc

+14-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
// readmissing -- read N missing keys in random order
3434
// readhot -- read N times in random order from 1% section of DB
3535
// seekrandom -- N random seeks
36+
// open -- cost of opening a DB
3637
// crc32c -- repeated crc32c of 4K of data
3738
// acquireload -- load N*1000 times
3839
// Meta operations:
@@ -442,7 +443,11 @@ class Benchmark {
442443
bool fresh_db = false;
443444
int num_threads = FLAGS_threads;
444445

445-
if (name == Slice("fillseq")) {
446+
if (name == Slice("open")) {
447+
method = &Benchmark::OpenBench;
448+
num_ /= 10000;
449+
if (num_ < 1) num_ = 1;
450+
} else if (name == Slice("fillseq")) {
446451
fresh_db = true;
447452
method = &Benchmark::WriteSeq;
448453
} else if (name == Slice("fillbatch")) {
@@ -702,6 +707,14 @@ class Benchmark {
702707
}
703708
}
704709

710+
void OpenBench(ThreadState* thread) {
711+
for (int i = 0; i < num_; i++) {
712+
delete db_;
713+
Open();
714+
thread->stats.FinishedSingleOp();
715+
}
716+
}
717+
705718
void WriteSeq(ThreadState* thread) {
706719
DoWrite(thread, true);
707720
}

0 commit comments

Comments
 (0)