P4C
The P4 Compiler
Loading...
Searching...
No Matches
timer.h
1#ifndef LIB_TIMER_H_
2#define LIB_TIMER_H_
3
4#include <cstddef>
5#include <functional>
6#include <memory>
7#include <string>
8#include <vector>
9
10namespace P4::Util {
11
25void withTimer(const char *timerName, const std::function<void()> &fn);
26
27struct TimerEntry {
29 std::string timerName;
34};
35
37std::vector<TimerEntry> getTimers();
38
39// Internal implementation.
40struct ScopedTimerCtx;
41
45 public:
46 explicit ScopedTimer(const char *name);
47 ScopedTimer(const ScopedTimer &) = delete;
49
50 private:
51 std::unique_ptr<ScopedTimerCtx> ctx;
52};
53
54} // namespace P4::Util
55
56#endif /* LIB_TIMER_H_ */
Definition timer.h:44
Definition timer.cpp:79
Definition timer.h:27
size_t milliseconds
Total duration in milliseconds.
Definition timer.h:31
float relativeToParent
Portion of this timer's name relative to the parent timer.
Definition timer.h:33
std::string timerName
Counter name. If a timer "Y" was invoked inside timer "X", its timer name is "X.Y".
Definition timer.h:29