KASKADE 7 development version
Public Member Functions | List of all members
Kaskade::ScopedTimingSection Class Reference

A scope guard object that automatically closes a timing section on destruction. More...

#include <timing.hh>

Detailed Description

A scope guard object that automatically closes a timing section on destruction.

This closes timing sections in case an exception is thrown.

Example:

{
ScopedTimingSection tsec("my expensive calculation");
f(); // f may throw an exception, timing will be stopped
}
A scope guard object that automatically closes a timing section on destruction.
Definition: timing.hh:181
See also
Timings

Definition at line 180 of file timing.hh.

Public Member Functions

 ScopedTimingSection ()
 Default constructor creating a not-running unnamed section. More...
 
 ScopedTimingSection (ScopedTimingSection const &)=delete
 
 ScopedTimingSection (Timings_Details::SectionBeacon const &sec)
 Move constructor. More...
 
 ScopedTimingSection (std::string const &name, bool gather=true)
 Constructor using the default timer provided by Timings::instance(). More...
 
 ScopedTimingSection (std::string const &name, Timings &timer, bool gather=true)
 Constructor using provided timer. More...
 
 ~ScopedTimingSection ()
 
void restart (std::string const &name)
 Start new section. More...
 
ScopedTimingSectionoperator= (Timings_Details::SectionBeacon const &sec)
 Assignment from a beacon. More...
 
void start ()
 Ensures the section is timed. More...
 
void stop ()
 Ensures the section is not timed. More...
 
bool isRunning () const
 Reports whether the section is currently timed. More...
 
Timingstimer ()
 Returns the used timer. More...
 

Constructor & Destructor Documentation

◆ ScopedTimingSection() [1/5]

Kaskade::ScopedTimingSection::ScopedTimingSection ( )

Default constructor creating a not-running unnamed section.

◆ ScopedTimingSection() [2/5]

Kaskade::ScopedTimingSection::ScopedTimingSection ( ScopedTimingSection const &  )
delete

◆ ScopedTimingSection() [3/5]

Kaskade::ScopedTimingSection::ScopedTimingSection ( Timings_Details::SectionBeacon const &  sec)

Move constructor.

This moves the given section to the created one, leaving the given section with empty name, not running, not gathering.

◆ ScopedTimingSection() [4/5]

Kaskade::ScopedTimingSection::ScopedTimingSection ( std::string const &  name,
bool  gather = true 
)

Constructor using the default timer provided by Timings::instance().

Parameters
namethe name of the section to be timed.
gatherif false, do not gather any timings. This can be used to switch off timing collection in potentially multithreaded environments, while at the same time use ScopedTimingSection guards. The timer is started immediately.

◆ ScopedTimingSection() [5/5]

Kaskade::ScopedTimingSection::ScopedTimingSection ( std::string const &  name,
Timings timer,
bool  gather = true 
)

Constructor using provided timer.

Parameters
timera timer. This has to exist during the lifetime of the scoped timing section.

The timer is started immediately.

◆ ~ScopedTimingSection()

Kaskade::ScopedTimingSection::~ScopedTimingSection ( )

Member Function Documentation

◆ isRunning()

bool Kaskade::ScopedTimingSection::isRunning ( ) const

Reports whether the section is currently timed.

◆ operator=()

ScopedTimingSection & Kaskade::ScopedTimingSection::operator= ( Timings_Details::SectionBeacon const &  sec)

Assignment from a beacon.

If the section is running, it is implicitly stopped by the assignment.

◆ restart()

void Kaskade::ScopedTimingSection::restart ( std::string const &  name)

Start new section.

If the section is running, it is implicitly stopped before the newly named section is started.

◆ start()

void Kaskade::ScopedTimingSection::start ( )

Ensures the section is timed.

If the timer is not running, it is started (unless gather is set to false). Otherwise nothing is done. A running section is stopped if assigned to.

◆ stop()

void Kaskade::ScopedTimingSection::stop ( )

Ensures the section is not timed.

If the timer is running, it is stopped. Otherwise nothing is done.

◆ timer()

Timings & Kaskade::ScopedTimingSection::timer ( )

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