fpmas 1.6
Public Member Functions | List of all members
fpmas::utils::perf::Probe Class Reference

#include <perf.h>

Inheritance diagram for fpmas::utils::perf::Probe:
Inheritance graph
[legend]
Collaboration diagram for fpmas::utils::perf::Probe:
Collaboration graph
[legend]

Public Member Functions

 Probe (std::string label)
 
 Probe (std::string label, std::function< bool()> condition)
 
std::string label () const override
 
std::vector< Duration > & durations () override
 
const std::vector< Duration > & durations () const override
 
void start () override
 
void stop () override
 
virtual std::string label () const =0
 
virtual std::vector< Duration > & durations ()=0
 
virtual const std::vector< Duration > & durations () const =0
 
virtual void start ()=0
 
virtual void stop ()=0
 

Detailed Description

fpmas::api::utils::perf::Probe implementation.

Constructor & Destructor Documentation

◆ Probe() [1/2]

fpmas::utils::perf::Probe::Probe ( std::string  label)
inline

Probe constructor.

Parameters
labelprobe label

◆ Probe() [2/2]

fpmas::utils::perf::Probe::Probe ( std::string  label,
std::function< bool()>  condition 
)
inline

Conditionnal probe constructor.

When start() is called, the probe effectively perform a measure if the condition is true. Notice that even if condition is false, stop() still must be called, even if it has no visible effect.

Even if any std::function can be provided, it might be useful to use lambda functions to easily define conditions.

example
bool measure = true;
fpmas::utils::perf::Probe probe("example", [&measure] () {return measure;});
probe.start();
probe.stop();
assert(probe.durations().size() == 1);
// Disables probe
measure = false;
probe.start();
probe.stop();
// No measure was performed
assert(probe.durations().size() == 1);
Definition: perf.h:23
void start() override
Definition: perf.cpp:7

Member Function Documentation

◆ label()

std::string fpmas::utils::perf::Probe::label ( ) const
inlineoverridevirtual

Label associated to measured data.

Notice that it is allowed to have several Probes associated to the same label.

Returns
probe label

Implements fpmas::api::utils::perf::Probe.

◆ durations() [1/2]

std::vector< Duration > & fpmas::utils::perf::Probe::durations ( )
inlineoverridevirtual

Returns a reference to durations currently buffered within this probe.

Since a reference is returned, the buffer can eventually be cleared by an external process.

Returns
reference to currently buffered durations

Implements fpmas::api::utils::perf::Probe.

◆ durations() [2/2]

const std::vector< Duration > & fpmas::utils::perf::Probe::durations ( ) const
inlineoverridevirtual

Returns a reference to durations currently buffered within this probe.

Returns
reference to currently buffered durations

Implements fpmas::api::utils::perf::Probe.

◆ start()

void fpmas::utils::perf::Probe::start ( )
overridevirtual

Starts a duration measurement with this probe.

Note
Starting an already running Probe currently produces an undefined behavior.

Implements fpmas::api::utils::perf::Probe.

◆ stop()

void fpmas::utils::perf::Probe::stop ( )
overridevirtual

Stops a duration measurement, previously started with start().

The duration between start() and end() calls is added to durations().

Note
Stopping a Probe that is not running currently produces an undefined behavior.

Implements fpmas::api::utils::perf::Probe.


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