Add a function to return current perf level

Summary: Add a function to return the perf level. It is to allow a wrapper of DB to increase the perf level and restore the original perf level after finishing the function call.

Test Plan: Add a verification in db_test

Reviewers: yhchiang, igor, ljin

Reviewed By: ljin

Subscribers: xjin, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D19551
This commit is contained in:
sdong 2014-07-10 11:35:07 -07:00
parent 30c81e7717
commit 36de0e5359
3 changed files with 9 additions and 0 deletions

View File

@ -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());
}

View File

@ -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.

View File

@ -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;