From 82b7e37f6eeb554332b2f0bc30bd218c65281f48 Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Thu, 31 Oct 2013 15:26:06 -0700 Subject: [PATCH] Fix a bug of table_reader_bench Summary: Iterator benchmark case is timed incorrectly. Fix it Test Plan: Run the benchmark Reviewers: haobo, dhruba Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D13845 --- table/table_reader_bench.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/table/table_reader_bench.cc b/table/table_reader_bench.cc index 369717e55..2c4c503d9 100644 --- a/table/table_reader_bench.cc +++ b/table/table_reader_bench.cc @@ -95,13 +95,13 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options, } std::string start_key = MakeKey(r1, r2); std::string end_key = MakeKey(r1, r2 + r2_len); - uint64_t first_part_time = 0; + uint64_t total_time = 0; uint64_t start_micros = env->NowMicros(); Iterator* iter = table_reader->NewIterator(read_options); int count = 0; for(iter->Seek(start_key); iter->Valid(); iter->Next()) { // verify key; - first_part_time = env->NowMicros() - start_micros; + total_time += env->NowMicros() - start_micros; assert(Slice(MakeKey(r1, r2 + count)) == iter->key()); start_micros = env->NowMicros(); if (++count >= r2_len) { @@ -115,7 +115,8 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options, assert(false); } delete iter; - hist.Add(first_part_time + env->NowMicros() - start_micros); + total_time += env->NowMicros() - start_micros; + hist.Add(total_time); } } } @@ -129,7 +130,7 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options, "num_key2: %5d %10s\n" "===================================================" "====================================================" - "\nHistogram (unit: nanoseconds): \n%s", + "\nHistogram (unit: microseconds): \n%s", tf->Name(), num_keys1, num_keys2, for_iterator? "iterator" : (if_query_empty_keys ? "empty" : "non_empty"), hist.ToString().c_str());