24 #include <ivi-logging.h> 29 typedef logging::DefaultLogContext LogContext;
32 #ifdef PROFILING_ENABLED 33 #define profilepoint(s) \ 35 #else // PROFILING_ENABLED 36 #define profilepoint(s) 41 #ifdef PROFILING_ENABLED 42 #define profilefunction(s) \ 44 #else // PROFILING_ENABLED 45 #define profilefunction(s) 50 LOG_DECLARE_CLASS_CONTEXT(
"PPRO",
"Profiler context");
53 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &m_time1);
54 log_warn() <<
"profiler " << s <<
" start " << format(m_time1);
59 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &m_time2);
60 timespec d = diff(m_time1, m_time2);
61 log_warn() <<
"profiler " << m_s <<
" end " << format(m_time2) <<
" " << format(d);
64 static void point(std::string s)
67 clock_gettime(CLOCK_REALTIME, &t);
68 log_warn() <<
"profilerPoint " << s <<
" " << PProfiler::format(t);
71 static std::string format(timespec t)
74 ss << std::setfill(
'0') << std::setw(1) << t.tv_sec <<
"." << std::setw(9) << t.tv_nsec;
78 timespec diff(timespec start, timespec end)
81 if ((end.tv_nsec-start.tv_nsec)<0) {
82 temp.tv_sec = end.tv_sec-start.tv_sec-1;
83 temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
85 temp.tv_sec = end.tv_sec-start.tv_sec;
86 temp.tv_nsec = end.tv_nsec-start.tv_nsec;
93 timespec m_time1, m_time2;