Spicy
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
hilti::rt::Profiler Class Reference

#include <profiler.h>

Public Member Functions

 Profiler ()=default
 
 Profiler (const Profiler &other)=delete
 
 Profiler (Profiler &&other)=default
 
 ~Profiler ()
 
Profileroperator= (const Profiler &other)=delete
 
Profileroperator= (Profiler &&other)=default
 
void record (const profiler::Measurement &end)
 
 operator bool () const
 

Static Public Member Functions

static profiler::Measurement snapshot (std::optional< uint64_t > volume=std::nullopt)
 

Protected Member Functions

 Profiler (std::string_view name, std::optional< uint64_t > volume)
 

Friends

std::optional< Profilerprofiler::start (std::string_view name, std::optional< uint64_t > volume)
 
void profiler::detail::done ()
 

Detailed Description

Class representing one block of code to profile. The constructor records a first measurement, and the destructor records a second. The delta between the two measurements is then added to a global total kept for respective block of code. Blocks are identified through descriptive names, which will be shows as part of the final report.

Profilers can't be instantiated directly; use the start() and stop() API instead.

Constructor & Destructor Documentation

◆ Profiler() [1/2]

hilti::rt::Profiler::Profiler ( )
default

Default constructor instantiating a no-op profiler that's not actively recording any measurement. The only purpose of constructor is allowing to pre-allocate a local profiler variable that a real profiler can later be move into.

◆ ~Profiler()

hilti::rt::Profiler::~Profiler ( )
inline

Destructor concluding any pending measurement.

◆ Profiler() [2/2]

hilti::rt::Profiler::Profiler ( std::string_view  name,
std::optional< uint64_t >  volume 
)
inlineprotected

Constructor starting a new measurement. Don't call directly, use profiler::start() instead.

Parameters
namedescriptive, unique name of the block of code to profile
volumeoptional initial absolute volume to record with the measurement

Member Function Documentation

◆ operator bool()

hilti::rt::Profiler::operator bool ( ) const
inline

Returns true if the profiler is currently taking an active measurement.

◆ record()

void Profiler::record ( const profiler::Measurement end)

Take final measurement and record the delta between first and final.

◆ snapshot()

profiler::Measurement Profiler::snapshot ( std::optional< uint64_t >  volume = std::nullopt)
static

Take and return a single measurement.

Parameters
volumeoptional current absolute volume to record with the measurement

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