Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
debug-counters.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_UTIL_DEBUG_COUNTERS_H
17 #define IMPALA_UTIL_DEBUG_COUNTERS_H
18 
19 #include "util/runtime-profile.h"
20 
21 #define ENABLE_DEBUG_COUNTERS 1
22 
23 namespace impala {
24 
34  public:
35  static RuntimeProfile& profile() {
36  static RuntimeProfile profile(new ObjectPool(), "DebugProfile");
37  return profile;
38  }
39 };
40 
41 #if ENABLE_DEBUG_COUNTERS
42 
43 #define DEBUG_SCOPED_TIMER(counter_name) \
44  COUNTER_SCOPED_TIMER(DebugRuntimeProfile::profile().AddCounter(counter_name, \
45  TUnit::CPU_TICKS))
46 
47 #define DEBUG_COUNTER_ADD(counter_name, v) \
48  COUNTER_ADD(DebugRuntimeProfile::profile().AddCounter(counter_name, \
49  TUnit::UNIT), v)
50 
51 #define DEBUG_COUNTER_SET(counter_name, v) \
52  COUNTER_SET(DebugRuntimeProfile::profile().AddCounter(counter_name, \
53  TUnit::UNIT), v)
54 
55 #define PRETTY_PRINT_DEBUG_COUNTERS(ostream_ptr) \
56  DebugRuntimeProfile::profile().PrettyPrint(ostream_ptr)
57 
58 #else
59 
60 #define DEBUG_SCOPED_TIMER(counter_name)
61 #define DEBUG_COUNTER_ADD(counter_name, v)
62 #define DEBUG_COUNTER_SET(counter_name, v)
63 #define PRETTY_PRINT_DEBUG_COUNTERS(ostream_ptr)
64 
65 #endif // ENABLE_DEBUG_COUNTERS
66 
67 }
68 
69 #endif // IMPALA_UTIL_DEBUG_COUNTERS_H
static RuntimeProfile & profile()