Jpp  17.1.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
time_tracking.hh
Go to the documentation of this file.
1 #ifndef TIME_TRACKING_HH
2 #define TIME_TRACKING_HH
3 
4 #include <fstream>
5 
6 #include <datatypespec.hh>
7 #include "chronometer.hpp"
8 
9 /**
10  * \author cpellegrino
11  */
12 
13 // NOTE: All the functions and classes inside this file expand to
14 // nothing if the BENCH_TIME macro is unset
15 
16 namespace benchmark {
17 
19 {
20  #ifdef BENCH_TIME
21  Chronometer m_ch;
22  #endif // BENCH_TIME
23 
24  friend
25  void chrono_set(chronometrable& chr);
26 
27  friend
28  void chrono_reset(chronometrable& chr);
29 
30  friend
31  void chrono_swap(chronometrable& input, chronometrable& output);
32 
33  template<typename Frame>
34  friend
35  void chrono_dump(const Frame& frame);
36 };
37 
38 inline
40 {
41  #ifdef BENCH_TIME
42  chr.m_ch.set();
43  #endif // BENCH_TIME
44 }
45 
46 inline
48 {
49  #ifdef BENCH_TIME
50  chr.m_ch.reset();
51  chr.m_ch.set();
52  #endif // BENCH_TIME
53 }
54 
55 inline
57 {
58  #ifdef BENCH_TIME
59  output.m_ch.swap(input.m_ch);
60  #endif // BENCH_TIME
61 }
62 
63 template<typename Frame>
64 inline
65 void chrono_dump(const Frame& frame)
66 {
67  #ifdef BENCH_TIME
68  if (frame.getHeader()->DataType == ttdc)
69  {
70  static std::ofstream g_perf_file("/dev/shm/opto_dq_perf_measure.txt", std::ios_base::app);
71  g_perf_file << frame.m_ch << '\n';
72  }
73  if (frame.getHeader()->DataType == taes)
74  {
75  static std::ofstream g_perf_file("/dev/shm/acou_dq_perf_measure.txt", std::ios_base::app);
76  g_perf_file << frame.m_ch << '\n';
77  }
78  #endif // BENCH_TIME
79 }
80 
81 } // ns benchmark
82 
83 #endif // TIME_TRACKING_HH
void chrono_set(chronometrable &chr)
friend void chrono_set(chronometrable &chr)
friend void chrono_swap(chronometrable &input, chronometrable &output)
void chrono_dump(const Frame &frame)
friend void chrono_dump(const Frame &frame)
void chrono_reset(chronometrable &chr)
const DAQCommonHeader *const getHeader() const
Definition: frame.hh:18
friend void chrono_reset(chronometrable &chr)
unsigned int const ttdc
Definition: datatypes.cpp:7
Template Frame for ARS data.
Definition: frame.hh:12
unsigned int const taes
Definition: datatypes.cpp:8
void chrono_swap(chronometrable &input, chronometrable &output)