#ifndef TIME_TRACKING_HH #define TIME_TRACKING_HH #include #include #include "chronometer.hpp" /** * \author cpellegrino */ // NOTE: All the functions and classes inside this file expand to // nothing if the BENCH_TIME macro is unset namespace benchmark { class chronometrable { #ifdef BENCH_TIME Chronometer m_ch; #endif // BENCH_TIME friend void chrono_set(chronometrable& chr); friend void chrono_reset(chronometrable& chr); friend void chrono_swap(chronometrable& input, chronometrable& output); template friend void chrono_dump(const Frame& frame); }; inline void chrono_set(chronometrable& chr) { #ifdef BENCH_TIME chr.m_ch.set(); #endif // BENCH_TIME } inline void chrono_reset(chronometrable& chr) { #ifdef BENCH_TIME chr.m_ch.reset(); chr.m_ch.set(); #endif // BENCH_TIME } inline void chrono_swap(chronometrable& input, chronometrable& output) { #ifdef BENCH_TIME output.m_ch.swap(input.m_ch); #endif // BENCH_TIME } template inline void chrono_dump(const Frame& frame) { #ifdef BENCH_TIME if (frame.getHeader()->DataType == ttdc) { static std::ofstream g_perf_file("/dev/shm/opto_dq_perf_measure.txt", std::ios_base::app); g_perf_file << frame.m_ch << '\n'; } if (frame.getHeader()->DataType == taes) { static std::ofstream g_perf_file("/dev/shm/acou_dq_perf_measure.txt", std::ios_base::app); g_perf_file << frame.m_ch << '\n'; } #endif // BENCH_TIME } } // ns benchmark #endif // TIME_TRACKING_HH