MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches

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()

Detailed Description

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

Definition at line 24 of file profile.h.

Member Typedef Documentation

◆ Clock

using mim::Profiler::Clock = std::chrono::steady_clock

Definition at line 26 of file profile.h.

◆ Duration

using mim::Profiler::Duration = Clock::duration

Definition at line 27 of file profile.h.

Member Function Documentation

◆ chrome_trace()

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().

◆ count()

void mim::Profiler::count ( std::string_view key,
uint64_t n = 1 )
inline

Adds n to counter key of the currently running Span; no-op if no Span is running or n is 0.

Definition at line 67 of file profile.h.

Referenced by mim::Phase::profile_count(), and summary().

◆ empty()

bool mim::Profiler::empty ( ) const
inline

Definition at line 45 of file profile.h.

◆ spans()

const auto & mim::Profiler::spans ( ) const
inline

Definition at line 46 of file profile.h.

◆ start()

void mim::Profiler::start ( std::string_view name)
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().

◆ stop()

void mim::Profiler::stop ( )
inline

Marks the end of the most recently started Phase run.

Definition at line 60 of file profile.h.

Referenced by mim::Phase::run().

◆ summary()

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().

◆ tree()

void mim::Profiler::tree ( std::ostream & os) const

Prints the Spans as an indented tree, preserving the order in which Phasees ran.

Definition at line 94 of file profile.cpp.

References No_Parent.

Referenced by main().

Member Data Documentation

◆ No_Parent

size_t mim::Profiler::No_Parent = std::numeric_limits<size_t>::max()
staticconstexpr

Definition at line 29 of file profile.h.

Referenced by start(), and tree().


The documentation for this class was generated from the following files: