fix compiler errors with -DNPERF_CONTEXT (#6642)

Summary:
as titled
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6642

Test Plan:
```
$ EXTRA_CXXFLAGS="-DNPERF_CONTEXT" DEBUG_LEVEL=0 make -j48 db_bench
```

Reviewed By: riversand963

Differential Revision: D20842313

Pulled By: ajkr

fbshipit-source-id: a830cad312ca681591f06749242279503b101df2
This commit is contained in:
Andrew Kryczka 2020-04-03 13:21:53 -07:00 committed by Facebook GitHub Bot
parent 259b6ec8da
commit e60ea7fe57
2 changed files with 12 additions and 3 deletions

View File

@ -10,6 +10,7 @@
namespace ROCKSDB_NAMESPACE {
namespace {
#ifndef NPERF_CONTEXT
Statistics* stats_for_report(Env* env, Statistics* stats) {
if (env != nullptr && stats != nullptr &&
stats->get_stats_level() > kExceptTimeForMutex) {
@ -18,6 +19,7 @@ Statistics* stats_for_report(Env* env, Statistics* stats) {
return nullptr;
}
}
#endif // NPERF_CONTEXT
} // namespace
void InstrumentedMutex::Lock() {

View File

@ -38,7 +38,9 @@ PerfContext::~PerfContext() {
}
PerfContext::PerfContext(const PerfContext& other) {
#ifndef NPERF_CONTEXT
#ifdef NPERF_CONTEXT
(void)other;
#else
user_key_comparison_count = other.user_key_comparison_count;
block_cache_hit_count = other.block_cache_hit_count;
block_read_count = other.block_read_count;
@ -133,7 +135,9 @@ PerfContext::PerfContext(const PerfContext& other) {
}
PerfContext::PerfContext(PerfContext&& other) noexcept {
#ifndef NPERF_CONTEXT
#ifdef NPERF_CONTEXT
(void)other;
#else
user_key_comparison_count = other.user_key_comparison_count;
block_cache_hit_count = other.block_cache_hit_count;
block_read_count = other.block_read_count;
@ -230,7 +234,9 @@ PerfContext::PerfContext(PerfContext&& other) noexcept {
// TODO(Zhongyi): reduce code duplication between copy constructor and
// assignment operator
PerfContext& PerfContext::operator=(const PerfContext& other) {
#ifndef NPERF_CONTEXT
#ifdef NPERF_CONTEXT
(void)other;
#else
user_key_comparison_count = other.user_key_comparison_count;
block_cache_hit_count = other.block_cache_hit_count;
block_read_count = other.block_read_count;
@ -443,6 +449,7 @@ void PerfContextByLevel::Reset() {
std::string PerfContext::ToString(bool exclude_zero_counters) const {
#ifdef NPERF_CONTEXT
(void)exclude_zero_counters;
return "";
#else
std::ostringstream ss;