diff --git a/db/db_test.cc b/db/db_test.cc index 3af33270e..4bc2942a8 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2355,6 +2355,7 @@ TEST(DBTest, NumImmutableMemTable) { std::string big_value(1000000 * 2, 'x'); std::string num; SetPerfLevel(kEnableTime);; + ASSERT_TRUE(GetPerfLevel() == kEnableTime); ASSERT_OK(dbfull()->Put(writeOpt, handles_[1], "k1", big_value)); ASSERT_TRUE(dbfull()->GetProperty(handles_[1], @@ -2417,6 +2418,7 @@ TEST(DBTest, NumImmutableMemTable) { // break if we change the default skiplist implementation ASSERT_EQ(num, "200"); SetPerfLevel(kDisable); + ASSERT_TRUE(GetPerfLevel() == kDisable); } while (ChangeCompactOptions()); } diff --git a/include/rocksdb/perf_context.h b/include/rocksdb/perf_context.h index 0704ea210..e96d09d2a 100644 --- a/include/rocksdb/perf_context.h +++ b/include/rocksdb/perf_context.h @@ -20,6 +20,9 @@ enum PerfLevel { // set the perf stats level void SetPerfLevel(PerfLevel level); +// get current perf stats level +PerfLevel GetPerfLevel(); + // A thread local context for gathering performance counter efficiently // and transparently. diff --git a/util/perf_context.cc b/util/perf_context.cc index 264b10d73..5443471d5 100644 --- a/util/perf_context.cc +++ b/util/perf_context.cc @@ -22,6 +22,10 @@ void SetPerfLevel(PerfLevel level) { perf_level = level; } +PerfLevel GetPerfLevel() { + return perf_level; +} + void PerfContext::Reset() { #if !defined(NPERF_CONTEXT) && !defined(IOS_CROSS_COMPILE) user_key_comparison_count = 0;