FE 0.13.1
Header-only C++ frontend library
Loading...
Searching...
No Matches

Records wall-clock timings for (possibly nested) named Profiler::Spans and reports them in various formats. More...

#include <fe/profile.h>

Classes

struct  Span
 A single 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 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 run; no-op if no Span is running.
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 they 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) named Profiler::Spans and reports them in various formats.

Spans nest like a stack, so each one remembers its parent. From these Spans the Profiler can derive

Definition at line 23 of file profile.h.

Member Typedef Documentation

◆ Clock

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

Definition at line 25 of file profile.h.

◆ Duration

using fe::Profiler::Duration = Clock::duration

Definition at line 26 of file profile.h.

Member Function Documentation

◆ chrome_trace()

void fe::Profiler::chrome_trace ( std::ostream & ) const

Dumps all Spans as Chrome Trace Event Format JSON.

◆ count()

void fe::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.

◆ empty()

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

Definition at line 44 of file profile.h.

◆ spans()

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

Definition at line 45 of file profile.h.

◆ start()

void fe::Profiler::start ( std::string_view name)
inline

Marks the start of a run named name.

Definition at line 52 of file profile.h.

References No_Parent.

◆ stop()

void fe::Profiler::stop ( )
inline

Marks the end of the most recently started run; no-op if no Span is running.

Definition at line 59 of file profile.h.

◆ summary()

void fe::Profiler::summary ( std::ostream & ) const

Prints a flat table aggregated by name, sorted by total time, descending.

◆ tree()

void fe::Profiler::tree ( std::ostream & ) const

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

Member Data Documentation

◆ No_Parent

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

Definition at line 28 of file profile.h.

Referenced by start().


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