/Users/deen/code/yugabyte-db/src/yb/util/stats/iostats_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_UTIL_STATS_IOSTATS_CONTEXT_IMP_H |
22 | | #define YB_UTIL_STATS_IOSTATS_CONTEXT_IMP_H |
23 | | |
24 | | #include "yb/util/stats/iostats_context.h" |
25 | | #include "yb/util/stats/perf_step_timer.h" |
26 | | |
27 | | #ifndef IOS_CROSS_COMPILE |
28 | | |
29 | | // increment a specific counter by the specified value |
30 | | #define IOSTATS_ADD(metric, value) \ |
31 | 51.5M | (yb::iostats_context.metric += value) |
32 | | |
33 | | // Increase metric value only when it is positive |
34 | | #define IOSTATS_ADD_IF_POSITIVE(metric, value) \ |
35 | 4.58M | if (value > 0) { IOSTATS_ADD(metric, value); } |
36 | | |
37 | | // reset a specific counter to zero |
38 | | #define IOSTATS_RESET(metric) \ |
39 | 221k | (yb::iostats_context.metric = 0) |
40 | | |
41 | | // reset all counters to zero |
42 | | #define IOSTATS_RESET_ALL(thread_pool_id) \ |
43 | | (yb::iostats_context.Reset(thread_pool_id)) |
44 | | |
45 | | #define IOSTATS_SET_THREAD_POOL_ID(value) \ |
46 | 119k | (yb::iostats_context.thread_pool_id = value) |
47 | | |
48 | | #define IOSTATS_THREAD_POOL_ID() \ |
49 | | (yb::iostats_context.thread_pool_id) |
50 | | |
51 | | #define IOSTATS(metric) \ |
52 | 168k | (yb::iostats_context.metric) |
53 | | |
54 | | // Declare and set start time of the timer |
55 | | #define IOSTATS_TIMER_GUARD(metric) \ |
56 | 85.8M | yb::PerfStepTimer iostats_step_timer_ ## metric(&(yb::iostats_context.metric)); \ |
57 | 85.8M | iostats_step_timer_ ## metric.Start(); |
58 | | |
59 | | #else // IOS_CROSS_COMPILE |
60 | | |
61 | | #define IOSTATS_ADD(metric, value) |
62 | | #define IOSTATS_ADD_IF_POSITIVE(metric, value) |
63 | | #define IOSTATS_RESET(metric) |
64 | | #define IOSTATS_RESET_ALL() |
65 | | #define IOSTATS_SET_THREAD_POOL_ID(value) |
66 | | #define IOSTATS_THREAD_POOL_ID() |
67 | | #define IOSTATS(metric) 0 |
68 | | |
69 | | #define IOSTATS_TIMER_GUARD(metric) |
70 | | |
71 | | #endif // IOS_CROSS_COMPILE |
72 | | |
73 | | #endif // YB_UTIL_STATS_IOSTATS_CONTEXT_IMP_H |