Records wall-clock timings for (possibly nested) Phase runs and reports them in various formats. More...
#include <mim/util/profile.h>
Classes | |
| struct | Span |
| A single Phase run. More... | |
Public Types | |
| using | Clock = std::chrono::steady_clock |
| using | Duration = Clock::duration |
Public Member Functions | |
Getters | |
| bool | empty () const |
| const auto & | spans () const |
Recording | |
Bracket a Phase run with Profiler::start / Profiler::stop; the calls must nest like a stack. | |
| void | start (std::string_view name) |
| void | stop () |
| Marks the end of the most recently started Phase run. | |
| void | count (std::string_view key, uint64_t n=1) |
Adds n to counter key of the currently running Span; no-op if no Span is running or n is 0. | |
Reporting | |
| void | summary (std::ostream &) const |
| void | tree (std::ostream &) const |
| Prints the Spans as an indented tree, preserving the order in which Phasees ran. | |
| void | chrome_trace (std::ostream &) const |
| Dumps all Spans as Chrome Trace Event Format JSON. | |
Static Public Attributes | |
| static constexpr size_t | No_Parent = std::numeric_limits<size_t>::max() |
Records wall-clock timings for (possibly nested) Phase runs and reports them in various formats.
Phasees nest: a PhaseMan runs sub-Phasees, so each run is recorded as a Profiler::Span that remembers its parent. From these Spans the Profiler can derive
| using mim::Profiler::Clock = std::chrono::steady_clock |
| using mim::Profiler::Duration = Clock::duration |
| void mim::Profiler::chrome_trace | ( | std::ostream & | os | ) | const |
Dumps all Spans as Chrome Trace Event Format JSON.
Definition at line 116 of file profile.cpp.
Referenced by main().
|
inline |
|
inline |
Marks the start of a Phase run named name.
Definition at line 53 of file profile.h.
References No_Parent.
Referenced by mim::Phase::run().
|
inline |
Marks the end of the most recently started Phase run.
Definition at line 60 of file profile.h.
Referenced by mim::Phase::run().
| void mim::Profiler::summary | ( | std::ostream & | os | ) | const |
Prints a flat table aggregated by Phase name, sorted by total time, descending.
Definition at line 47 of file profile.cpp.
References count().
Referenced by main().
| void mim::Profiler::tree | ( | std::ostream & | os | ) | const |
|
staticconstexpr |