3 #ifndef BASE_PROFILER_H
4 #define BASE_PROFILER_H
19 typedef unsigned long long clock_t;
27 uint64_t virtual_timer_value;
28 asm volatile(
"mrs %0, cntvct_el0" :
"=r"(virtual_timer_value));
29 return virtual_timer_value;
32 asm volatile (
"rdtsc" :
"=a" (low),
"=d" (high));
33 return (clock_t(high) << 32) | low;
46 std::vector<Entry> fEntries;
56 while (fEntries.size() < num)
57 fEntries.emplace_back();
74 Profiler::clock_t fLast{0};
80 if (!fProfiler.fActive || (fCnt >= fProfiler.fEntries.size()))
83 fLast = fProfiler.GetClock();
85 if (name && fProfiler.fEntries[fCnt].fName.empty())
86 fProfiler.fEntries[fCnt].fName = name;
96 void Next(
const char *name =
nullptr,
unsigned lvl = 0)
98 if (!fProfiler.fActive || (fCnt >= fProfiler.fEntries.size()))
101 auto now = fProfiler.GetClock();
103 fProfiler.fEntries[fCnt].fSum += (now - fLast);
107 if (lvl) fCnt = lvl;
else fCnt++;
109 if (name && (fCnt < fProfiler.fEntries.size()) && fProfiler.fEntries[fCnt].fName.empty())
110 fProfiler.fEntries[fCnt].fName = name;
Guard class to use base::Profiler.
Definition: Profiler.h:71
~ProfilerGuard()
destructor
Definition: Profiler.h:90
ProfilerGuard(Profiler &prof, const char *name=nullptr, unsigned lvl=0)
constructor
Definition: Profiler.h:78
void Next(const char *name=nullptr, unsigned lvl=0)
next ?
Definition: Profiler.h:96
Performance profiler.
Definition: Profiler.h:15
void MakeStatistic()
make statistic
Definition: Profiler.cxx:6
std::string Format()
format
Definition: Profiler.cxx:26
void SetActive(bool on=true)
set active
Definition: Profiler.h:61
Profiler()
constructor
Definition: Profiler.h:51
void Reserve(unsigned num=10)
reserve
Definition: Profiler.h:54