Skip to content

Commit

Permalink
fix formatting and styling issues.
Browse files Browse the repository at this point in the history
Co-authored-by: Xinye Tao <xy.tao@outlook.com>
Signed-off-by: lemonhx <lemonhx@lemonhx.tech>
  • Loading branch information
LemonHX and tabokie committed Aug 11, 2021
1 parent 4ff539b commit c05a112
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 33 deletions.
44 changes: 22 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -965,28 +965,28 @@ if(WITH_TESTS)
encryption/encryption_test.cc
env/env_basic_test.cc
env/env_test.cc
env/mock_env_test.cc
file/delete_scheduler_test.cc
logging/auto_roll_logger_test.cc
logging/env_logger_test.cc
logging/event_logger_test.cc
memory/arena_test.cc
memtable/inlineskiplist_test.cc
memtable/skiplist_test.cc
memtable/write_buffer_manager_test.cc
monitoring/histogram_test.cc
monitoring/perf_flag_test.cc
monitoring/iostats_context_test.cc
monitoring/statistics_test.cc
monitoring/stats_history_test.cc
options/options_settable_test.cc
options/options_test.cc
table/block_based/block_based_filter_block_test.cc
table/block_based/block_test.cc
table/block_based/data_block_hash_index_test.cc
table/block_based/full_filter_block_test.cc
table/block_based/partitioned_filter_block_test.cc
table/cleanable_test.cc
env/mock_env_test.cc
file/delete_scheduler_test.cc
logging/auto_roll_logger_test.cc
logging/env_logger_test.cc
logging/event_logger_test.cc
memory/arena_test.cc
memtable/inlineskiplist_test.cc
memtable/skiplist_test.cc
memtable/write_buffer_manager_test.cc
monitoring/histogram_test.cc
monitoring/perf_flag_test.cc
monitoring/iostats_context_test.cc
monitoring/statistics_test.cc
monitoring/stats_history_test.cc
options/options_settable_test.cc
options/options_test.cc
table/block_based/block_based_filter_block_test.cc
table/block_based/block_test.cc
table/block_based/data_block_hash_index_test.cc
table/block_based/full_filter_block_test.cc
table/block_based/partitioned_filter_block_test.cc
table/cleanable_test.cc
table/cuckoo/cuckoo_table_builder_test.cc
table/cuckoo/cuckoo_table_reader_test.cc
table/merger_test.cc
Expand Down
8 changes: 4 additions & 4 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2753,16 +2753,16 @@ void rocksdb_set_perf_level(int v) {
SetPerfLevel(level);
}

void rocksdb_enable_perf_flag(uint64_t flag){
void rocksdb_enable_perf_flag(uint64_t flag) {
EnablePerfFlag(flag);
}

void rocksdb_disable_perf_flag(uint64_t flag){
void rocksdb_disable_perf_flag(uint64_t flag) {
DisablePerfFlag(flag);
}

int rocksdb_check_perf_flag(uint64_t flag){
return (int)CheckPerfFlag(flag);
int rocksdb_check_perf_flag(uint64_t flag) {
return static_cast<int>(CheckPerfFlag(flag));
}

rocksdb_perfcontext_t* rocksdb_perfcontext_create() {
Expand Down
4 changes: 2 additions & 2 deletions include/rocksdb/perf_flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
(((uint64_t)FLAG_END & (uint64_t)0b111) == 0 \
? ((uint64_t)FLAG_END >> (uint64_t)0b11) \
: ((uint64_t)FLAG_END >> (uint64_t)0b11) + (uint64_t)1)
namespace rocksdb{
namespace rocksdb {
void EnablePerfFlag(uint64_t flag);
void DisablePerfFlag(uint64_t flag);
bool CheckPerfFlag(uint64_t flag);
}
} // namespace rocksdb

#define GET_FLAG(flag) perf_flags[(uint64_t)(flag) >> (uint64_t)0b11]
#include "perf_flag_defs.h"
2 changes: 1 addition & 1 deletion monitoring/perf_context_imp.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern thread_local PerfContext perf_context;

// Declare and set start time of the timer
#define PERF_TIMER_GUARD(metric) \
PerfStepTimer perf_step_timer_##metric(&(perf_context.metric),CheckPerfFlag(flag_##metric)); \
PerfStepTimer perf_step_timer_##metric(&(perf_context.metric), CheckPerfFlag(flag_##metric)); \
perf_step_timer_##metric.Start();

// Declare and set start time of the timer
Expand Down
6 changes: 3 additions & 3 deletions monitoring/perf_flag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ uint8_t perf_flags[FLAGS_LEN] = {0};
void EnablePerfFlag(uint64_t flag) {
if (CheckPerfFlag(flag)) {
} else {
// & 0b111 means find the flag location is a alternative way to do mod operation
// & 0b111 means find the flag location is a alternative way to do mod
// operation
GET_FLAG(flag) ^= (uint64_t)0b1 << ((uint64_t)flag & (uint64_t)0b111);
}
}

void DisablePerfFlag(uint64_t flag) {
if (CheckPerfFlag(flag)) {
GET_FLAG(flag) ^= (uint64_t)0b1 << ((uint64_t)flag & (uint64_t)0b111);
} else {
}
}

Expand All @@ -27,4 +27,4 @@ bool CheckPerfFlag(uint64_t flag) {
<< (flag & (uint64_t)0b111)) != 0;
}

} // namespace rocksdb
} // namespace rocksdb
4 changes: 3 additions & 1 deletion monitoring/perf_flag_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@

namespace rocksdb {
class PerfFlagTest : testing::Test {};

TEST(PerfFlagTest, TestEnableFlag) {
for (int i = 0; i < 10; ++i) {
EnablePerfFlag(i);
ASSERT_EQ(CheckPerfFlag(i), true);
}
}

TEST(PerfFlagTest, TestDisableFlag) {
for (int i = 0; i < 10; ++i) {
EnablePerfFlag(i);
Expand Down Expand Up @@ -79,4 +81,4 @@ TEST(PerfFlagTest, TestPerfLevelOverLappingPerfFlag) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
}

0 comments on commit c05a112

Please sign in to comment.