10 #include <hilti/rt/configuration.h>
11 #include <hilti/rt/global-state.h>
12 #include <hilti/rt/profiler-state.h>
20 std::optional<Profiler> start(std::string_view name, std::optional<uint64_t> volume = std::nullopt);
21 void stop(std::optional<Profiler>& p, std::optional<uint64_t> volume = std::nullopt);
67 operator bool()
const {
return ! _name.empty(); }
84 Profiler(std::string_view name, std::optional<uint64_t> volume) : _name(name), _start(
snapshot(volume)) {
89 friend std::optional<Profiler> profiler::start(std::string_view name, std::optional<uint64_t> volume);
90 friend void profiler::detail::done();
92 void _register()
const;
108 inline std::optional<Profiler> start(std::string_view name, std::optional<uint64_t> volume) {
109 if ( ::hilti::rt::detail::unsafeGlobalState()->profiling_enabled )
110 return Profiler(name, volume);
122 inline void stop(std::optional<Profiler>& p, std::optional<uint64_t> volume) {
134 std::optional<Measurement> get(
const std::string& name);
137 extern void report();
Definition: profiler.h:45
Profiler(std::string_view name, std::optional< uint64_t > volume)
Definition: profiler.h:84
void record(const profiler::Measurement &end)
Definition: profiler.cc:43
~Profiler()
Definition: profiler.h:58
static profiler::Measurement snapshot(std::optional< uint64_t > volume=std::nullopt)
Definition: profiler.cc:33
void done()
Definition: init.cc:64
void init()
Definition: init.cc:21
Definition: profiler-state.h:22