bactria  0.0.1
The bactria library is a header-only C++14 library for profiling and tracing.
bactria::metrics::Sector< TTag > Class Template Referencefinal

The sector class. More...

#include <Sector.hpp>

Public Member Functions

 Sector ()=default
 The default constructor. More...
 
 Sector (std::string sector_name)
 The non-entering constructor. More...
 
 Sector (std::string sector_name, std::string source, std::uint32_t lineno, std::string caller)
 The entering constructor. More...
 
 Sector (Sector const &)=delete
 The copy constructor (deleted). More...
 
auto operator= (Sector const &) -> Sector &=delete
 The copy assignment operator (deleted). More...
 
 Sector (Sector &&other)
 The move constructor. More...
 
auto operator= (Sector &&rhs) -> Sector &
 The move assignment operator. More...
 
 ~Sector ()
 The destructor. More...
 
auto enter (std::string source, std::uint32_t lineno, std::string caller) -> void
 Enter the sector. More...
 
auto leave (std::string source, std::uint32_t lineno, std::string caller) -> void
 Leave the sector. More...
 
auto summary () -> void
 Summarize the Sector. More...
 
auto on_enter (std::function< void(void)> f) -> void
 Define an enter action. More...
 
auto on_leave (std::function< void(void)> f) -> void
 Define a leave action. More...
 

Detailed Description

template<typename TTag = Generic>
class bactria::metrics::Sector< TTag >

The sector class.

This class can be instantiated to instrument portions of the application code. The concrete metrics collected by this class are backend-specific.

See also
Phase

Constructor & Destructor Documentation

◆ Sector() [1/5]

template<typename TTag = Generic>
bactria::metrics::Sector< TTag >::Sector ( )
default

The default constructor.

The default constructor will generate a sector with the name BACTRIA_GENERIC_SECTOR. This sector will not be entered; this still needs to be done with a (correctly nested) pair of bactria_Enter() and bactria_Leave() or ~Sector().

See also
bactria_Enter, bactria_Leave, ~Sector

◆ Sector() [2/5]

template<typename TTag = Generic>
bactria::metrics::Sector< TTag >::Sector ( std::string  sector_name)
inline

The non-entering constructor.

The non-entering constructor will generate a sector with the name name. This sector will not be entered; this still needs to be done with a (correctly nested) pair of bactria_Enter() and bactria_Leave() or ~Sector().

Parameters
sector_nameThe sector name as it should appear on the output file or visualizer.
See also
bactria_Enter, bactria_Leave, ~Sector

◆ Sector() [3/5]

template<typename TTag = Generic>
bactria::metrics::Sector< TTag >::Sector ( std::string  sector_name,
std::string  source,
std::uint32_t  lineno,
std::string  caller 
)
inline

The entering constructor.

The entering constructor will generate a sector with the name name. This sector will be entered immediately. To leave it, the user can call bactria_Leave() or wait for ~Sector() to be triggered.

Parameters
sector_nameThe sector name as it should appear on the output file or visualizer.
sourceThe source file this sector should be assigned to. This should be __FILE__.
linenoThe line number of the source file. This should be __LINE__.
callerThe surrounding function this sector is constructed in. This should be __func__.
See also
bactria_Enter, bactria_Leave, ~Sector()

◆ Sector() [4/5]

template<typename TTag = Generic>
bactria::metrics::Sector< TTag >::Sector ( Sector< TTag > const &  )
delete

The copy constructor (deleted).

Sectors are not intended to be copied. Thus, the copy constructor is deleted.

◆ Sector() [5/5]

template<typename TTag = Generic>
bactria::metrics::Sector< TTag >::Sector ( Sector< TTag > &&  other)
inline

The move constructor.

Moves the other sector into this sector.

Parameters
otherThe sector to be moved.

◆ ~Sector()

template<typename TTag = Generic>
bactria::metrics::Sector< TTag >::~Sector ( )
inline

The destructor.

Destructs the sector. If the sector was entered and there was no preceeding call to bactria_Leave() or leave() the destructor will trigger this functionality before the contents of this are deleted.

See also
Sector(), bactria_Enter, bactria_Leave, enter, leave

Member Function Documentation

◆ enter()

template<typename TTag = Generic>
auto bactria::metrics::Sector< TTag >::enter ( std::string  source,
std::uint32_t  lineno,
std::string  caller 
) -> void
inline

Enter the sector.

Enters the sector. It is not allowed to enter a sector multiple times without a prior call to leave(). Each call to enter() has to be correctly nested with a corresponding call to leave() or ~Sector().

Parameters
sourceThe source file where the sector is entered. This should be __FILE__.
linenoThe source line where the sector is entered. This should be __LINE__.
callerThe function where the sector is entered. This should be __func__.
See also
bactria_Enter, bactria_Leave, leave, ~Sector

◆ leave()

template<typename TTag = Generic>
auto bactria::metrics::Sector< TTag >::leave ( std::string  source,
std::uint32_t  lineno,
std::string  caller 
) -> void
inline

Leave the sector.

Leaves the sector.

Parameters
sourceThe source file where the sector is left. This should be __FILE__.
linenoThe source line where the sector is left. This should be __LINE__.
callerThe function where the sector is left. This should be __func__.
See also
bactria_Enter, enter, bactria_Leave, Sector()

◆ on_enter()

template<typename TTag = Generic>
auto bactria::metrics::Sector< TTag >::on_enter ( std::function< void(void)>  f) -> void
inline

Define an enter action.

Defines an action which is executed after the Sector is entered. This allows for injecting user-defined actions that alter program behaviour, such as issuing asynchronous functions. Actions will not be executed if bactria has been deactivated by setting the environment variable BACTRIA_DEACTIVATE.

Parameters
[in]fThe action to be executed after entering the Sector.
See also
enter, on_leave

◆ on_leave()

template<typename TTag = Generic>
auto bactria::metrics::Sector< TTag >::on_leave ( std::function< void(void)>  f) -> void
inline

Define a leave action.

Defines an action which is executed before the Sector is left. This allows for injecting user-defined actions that alter program behaviour, such as synchronization of asynchronous functions. Actions will not be executed if bactria has been deactivated by setting the environment variable BACTRIA_DEACTIVATE.

Parameters
[in]fThe action to be executed before leaving the Sector.
See also
leave, on_enter

◆ operator=() [1/2]

template<typename TTag = Generic>
auto bactria::metrics::Sector< TTag >::operator= ( Sector< TTag > &&  rhs) -> Sector&
inline

The move assignment operator.

Moves the rhs sector into this sector.

Parameters
rhsThe sector to be moved.

◆ operator=() [2/2]

template<typename TTag = Generic>
auto bactria::metrics::Sector< TTag >::operator= ( Sector< TTag > const &  ) -> Sector &=delete
delete

The copy assignment operator (deleted).

Sectors are not intended to be copied. Thus, the copy assignment operator is deleted.

◆ summary()

template<typename TTag = Generic>
auto bactria::metrics::Sector< TTag >::summary ( ) -> void
inline

Summarize the Sector.

Summarizes the Sector's metrics. The exact metrics depend on the back-end. This function is mostly useful for Sectors with the Body tag which allows the back-end to evaluate the individual iterations and generate statistics for the overall loop. If this method has not been called before destruction, the destructor will call this internally.


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