/Users/deen/code/yugabyte-db/src/yb/rocksdb/util/perf_context_imp.h
Line | Count | Source |
1 | | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | | // This source code is licensed under the BSD-style license found in the |
3 | | // LICENSE file in the root directory of this source tree. An additional grant |
4 | | // of patent rights can be found in the PATENTS file in the same directory. |
5 | | // |
6 | | // The following only applies to changes made to this file as part of YugaByte development. |
7 | | // |
8 | | // Portions Copyright (c) YugaByte, Inc. |
9 | | // |
10 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
11 | | // in compliance with the License. You may obtain a copy of the License at |
12 | | // |
13 | | // http://www.apache.org/licenses/LICENSE-2.0 |
14 | | // |
15 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
16 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
17 | | // or implied. See the License for the specific language governing permissions and limitations |
18 | | // under the License. |
19 | | // |
20 | | |
21 | | #ifndef YB_ROCKSDB_UTIL_PERF_CONTEXT_IMP_H |
22 | | #define YB_ROCKSDB_UTIL_PERF_CONTEXT_IMP_H |
23 | | |
24 | | #include "yb/rocksdb/perf_context.h" |
25 | | |
26 | | namespace rocksdb { |
27 | | |
28 | | #if defined(NPERF_CONTEXT) || defined(IOS_CROSS_COMPILE) |
29 | | |
30 | | #define PERF_TIMER_GUARD(metric) |
31 | | #define PERF_CONDITIONAL_TIMER_FOR_MUTEX_GUARD(metric, condition) |
32 | | #define PERF_TIMER_MEASURE(metric) |
33 | | #define PERF_TIMER_STOP(metric) |
34 | | #define PERF_TIMER_START(metric) |
35 | | #define PERF_COUNTER_ADD(metric, value) |
36 | | |
37 | | #else |
38 | | |
39 | | // Stop the timer and update the metric |
40 | | #define PERF_TIMER_STOP(metric) \ |
41 | 37.4M | perf_step_timer_ ## metric.Stop(); |
42 | | |
43 | | #define PERF_TIMER_START(metric) \ |
44 | 28.8M | perf_step_timer_ ## metric.Start(); |
45 | | |
46 | | // Declare and set start time of the timer |
47 | | #define PERF_TIMER_GUARD(metric) \ |
48 | 2.37G | ::yb::PerfStepTimer perf_step_timer_ ## metric(&(perf_context.metric)); \ |
49 | 2.37G | perf_step_timer_ ## metric.Start(); |
50 | | |
51 | | #define PERF_CONDITIONAL_TIMER_FOR_MUTEX_GUARD(metric, condition) \ |
52 | 199M | ::yb::PerfStepTimer perf_step_timer_##metric(&(perf_context.metric), true); \ |
53 | 199M | if ((condition)) { \ |
54 | 199M | perf_step_timer_##metric.Start(); \ |
55 | 199M | } |
56 | | |
57 | | // Update metric with time elapsed since last START. start time is reset |
58 | | // to current timestamp. |
59 | | #define PERF_TIMER_MEASURE(metric) \ |
60 | | perf_step_timer_ ## metric.Measure(); |
61 | | |
62 | | // Increase metric value |
63 | | #define PERF_COUNTER_ADD(metric, value) \ |
64 | 29.2G | perf_context.metric += value; |
65 | | |
66 | | #endif |
67 | | |
68 | | } // namespace rocksdb |
69 | | |
70 | | #endif // YB_ROCKSDB_UTIL_PERF_CONTEXT_IMP_H |