Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
IncidenceCount Class Reference

#include "lib/incidence-count.hpp"

Description

A recorder for concurrent incidences.

Start and end of individual activations are recorded by direct calls, automatically detecting the thread identity; for further differentiation, an additional caseID can be given. Accumulated observations can be integrated into a statistics evaluation.

Warning
never operate multiple instances of this helper at the same time

Definition at line 65 of file incidence-count.hpp.

Classes

struct  Inc
 
struct  Statistic
 

Public Member Functions

 IncidenceCount ()=default
 
IncidenceCountexpectThreads (uint8_t cnt)
 
IncidenceCountexpectIncidents (size_t cnt)
 
void markEnter (uint8_t caseID=0)
 
void markLeave (uint8_t caseID=0)
 
Statistic evaluate ()
 Visit all data captured thus far, construct an unified timeline and then compute statistics evaluations to characterise observations.
 
double calcCumulatedTime ()
 

Private Types

using TIMING_SCALE = std::micro
 
using Clock = std::chrono::steady_clock
 
using Instance = decltype(Clock::now())
 
using Dur = std::chrono::duration< double, TIMING_SCALE >
 
using Sequence = vector< Inc >
 
using Recording = vector< Sequence >
 

Private Member Functions

uint8_t allocateNextSlot ()
 threadsafe allocation of thread/slotID
 
uint8_t getMySlot ()
 
SequencegetMySequence (uint8_t threadID)
 
void addEntry (uint8_t caseID, bool isLeave)
 
- Private Member Functions inherited from NonCopyable
 ~NonCopyable ()=default
 
 NonCopyable ()=default
 
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Private Attributes

Recording rec_
 
std::atomic_uint8_t slotID_ {0}
 

Constructor & Destructor Documentation

◆ IncidenceCount()

IncidenceCount ( )
default

Class Documentation

◆ lib::IncidenceCount::Inc

struct lib::IncidenceCount::Inc
Class Members
Instance when
uint8_t thread:8
uint8_t caseID:8
bool isLeave:1
+ Collaboration diagram for IncidenceCount::Inc:

Member Typedef Documentation

◆ TIMING_SCALE

using TIMING_SCALE = std::micro
private

Definition at line 68 of file incidence-count.hpp.

◆ Clock

using Clock = std::chrono::steady_clock
private

Definition at line 69 of file incidence-count.hpp.

◆ Instance

using Instance = decltype(Clock::now())
private

Definition at line 71 of file incidence-count.hpp.

◆ Dur

using Dur = std::chrono::duration<double, TIMING_SCALE>
private

Definition at line 72 of file incidence-count.hpp.

◆ Sequence

using Sequence = vector<Inc>
private

Definition at line 82 of file incidence-count.hpp.

◆ Recording

using Recording = vector<Sequence>
private

Definition at line 83 of file incidence-count.hpp.

Member Function Documentation

◆ allocateNextSlot()

uint8_t allocateNextSlot ( )
inlineprivate

threadsafe allocation of thread/slotID

Definition at line 91 of file incidence-count.hpp.

References IncidenceCount::slotID_.

Referenced by IncidenceCount::getMySlot().

+ Here is the caller graph for this function:

◆ getMySlot()

uint8_t getMySlot ( )
inlineprivate

Definition at line 97 of file incidence-count.hpp.

References IncidenceCount::allocateNextSlot().

Referenced by IncidenceCount::addEntry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMySequence()

Sequence & getMySequence ( uint8_t  threadID)
inlineprivate

Definition at line 105 of file incidence-count.hpp.

References IncidenceCount::rec_.

Referenced by IncidenceCount::addEntry().

+ Here is the caller graph for this function:

◆ addEntry()

void addEntry ( uint8_t  caseID,
bool  isLeave 
)
inlineprivate

Definition at line 117 of file incidence-count.hpp.

References IncidenceCount::Inc::caseID, IncidenceCount::getMySequence(), IncidenceCount::getMySlot(), IncidenceCount::Inc::isLeave, IncidenceCount::Inc::thread, and IncidenceCount::Inc::when.

Referenced by IncidenceCount::markEnter(), and IncidenceCount::markLeave().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expectThreads()

IncidenceCount & expectThreads ( uint8_t  cnt)
inline

Definition at line 134 of file incidence-count.hpp.

References IncidenceCount::rec_.

◆ expectIncidents()

IncidenceCount & expectIncidents ( size_t  cnt)
inline

Definition at line 142 of file incidence-count.hpp.

References IncidenceCount::rec_.

◆ markEnter()

void markEnter ( uint8_t  caseID = 0)
inline

Definition at line 154 of file incidence-count.hpp.

References IncidenceCount::addEntry().

Referenced by RandomChainCalcFunctor< maxFan >::invokeJobOperation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ markLeave()

void markLeave ( uint8_t  caseID = 0)
inline

Definition at line 155 of file incidence-count.hpp.

References IncidenceCount::addEntry().

Referenced by RandomChainCalcFunctor< maxFan >::invokeJobOperation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ evaluate()

IncidenceCount::Statistic evaluate ( )
inline

Visit all data captured thus far, construct an unified timeline and then compute statistics evaluations to characterise observations.

Warning
caller must ensure there was a barrier or visibility sync before invocation.

Definition at line 207 of file incidence-count.hpp.

References IncidenceCount::Statistic::activationCnt, IncidenceCount::Statistic::activeTime, IncidenceCount::Statistic::avgConcurrency, IncidenceCount::Statistic::caseCntr, IncidenceCount::Statistic::caseTime, IncidenceCount::Statistic::concTime, IncidenceCount::Statistic::coveredTime, IncidenceCount::Statistic::cumulatedTime, IncidenceCount::Statistic::eventCnt, lib::explore(), IncidenceCount::rec_, IncidenceCount::Statistic::thrdCntr, and IncidenceCount::Statistic::thrdTime.

Referenced by IncidenceCount::calcCumulatedTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calcCumulatedTime()

double calcCumulatedTime ( )
inline

Definition at line 192 of file incidence-count.hpp.

References IncidenceCount::Statistic::cumulatedTime, and IncidenceCount::evaluate().

+ Here is the call graph for this function:

Member Data Documentation

◆ rec_

◆ slotID_

std::atomic_uint8_t slotID_ {0}
private

Definition at line 87 of file incidence-count.hpp.

Referenced by IncidenceCount::allocateNextSlot().

+ Inheritance diagram for IncidenceCount:
+ Collaboration diagram for IncidenceCount:

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