EII Message Bus C Reference
profiling.h
Go to the documentation of this file.
1 // Copyright (c) 2019 Intel Corporation.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 
26 #ifndef _EII_UTILS_PROFILING_H
27 #define _EII_UTILS_PROFILING_H
28 
29 #include <chrono>
30 #include <string>
32 #include <eii/utils/config.h>
33 #include <eii/utils/logger.h>
34 
35 namespace eii {
36 namespace utils {
37 
38 class Profiling {
39 private:
40  // flag for if profiling enabled
41  bool m_profiling_enabled;
42 
43 public:
49  Profiling();
50 
56  bool is_profiling_enabled();
57 
68  void add_profiling_ts(msg_envelope_t* meta_data, const char* key);
69 
77 };
78 
79 //Macros for ease of use by calling modules
80 #define DO_PROFILING(profile, meta, ts_key) \
81  if(profile->is_profiling_enabled()) { \
82  profile->add_profiling_ts(meta, ts_key); \
83  }
84 
85 } // namespace utils
86 } // namespace eii
87 
88 #endif
msg_envelope.h
Messaging envelope abstraction.
msg_envelope_t
Definition: msg_envelope.h:111
eii::utils::Profiling
Definition: profiling.h:38
eii::utils::Profiling::add_profiling_ts
void add_profiling_ts(msg_envelope_t *meta_data, const char *key)
eii::utils::Profiling::get_curr_time_as_int_epoch
int64_t get_curr_time_as_int_epoch()
eii::utils::Profiling::Profiling
Profiling()
eii::utils::Profiling::is_profiling_enabled
bool is_profiling_enabled()