ATLAS Offline Software
Loading...
Searching...
No Matches
PMonUtils::CustomBenchmark Class Reference

#include <CustomBenchmark.h>

Collaboration diagram for PMonUtils::CustomBenchmark:

Classes

struct  Data

Public Member Functions

 CustomBenchmark (unsigned nmax)
 ~CustomBenchmark ()
void begin (unsigned id)
void end (int count)
void getData (unsigned id, uint64_t &count, double &time_ms) const
unsigned nMax () const
unsigned size () const

Private Member Functions

 CustomBenchmark (const CustomBenchmark &)
CustomBenchmarkoperator= (const CustomBenchmark &)

Static Private Member Functions

static int64_t clock_nooverflow ()

Private Attributes

const unsigned m_nmax
Datam_data
Datam_data_current

Detailed Description

Definition at line 30 of file CustomBenchmark.h.

Constructor & Destructor Documentation

◆ CustomBenchmark() [1/2]

PMonUtils::CustomBenchmark::CustomBenchmark ( unsigned nmax)

Definition at line 9 of file CustomBenchmark.cxx.

10 : m_nmax(nmax),
11 m_data(new Data[nmax]),
13 {
14 Data * itE = &(m_data[m_nmax]);
15 for (Data * it = m_data; it!=itE; ++it)
16 it->init();
17 }
const int nmax(200)

◆ ~CustomBenchmark()

PMonUtils::CustomBenchmark::~CustomBenchmark ( )

Definition at line 19 of file CustomBenchmark.cxx.

20 {
21 delete[] m_data;
22 }

◆ CustomBenchmark() [2/2]

PMonUtils::CustomBenchmark::CustomBenchmark ( const CustomBenchmark & )
private

Member Function Documentation

◆ begin()

void PMonUtils::CustomBenchmark::begin ( unsigned id)
inline

Definition at line 67 of file CustomBenchmark.h.

68 {
69 assert(id<m_nmax);
71 m_data_current->time_at_begin = clock_nooverflow();
72 }
static int64_t clock_nooverflow()

◆ clock_nooverflow()

int64_t PMonUtils::CustomBenchmark::clock_nooverflow ( )
inlinestaticprivate

Definition at line 89 of file CustomBenchmark.h.

89 {
90 //Copied from PerfMonComps/trunk/src/SemiDetMisc.h
91 //
92 //In gnu, clock_t is a long and CLOCKS_PER_SECOND 1000000 so clock()
93 //will overflow in 32bit builds after a few thousands of seconds. To
94 //avoid this, we have the following method instead which notices when
95 //overflow occurs and corrects for it (it won't notice if it doesn't
96 //get called for >4000s, but this should be ok for almost all of our
97 //use cases):
98 assert(std::numeric_limits<clock_t>::is_integer);
99 if (sizeof(clock_t)>=sizeof(int64_t))
100 return clock();//64bit builds shouldn't have overflow issues.
101
102 //not so clean with statics i guess:
103 static clock_t last=clock();
104 static int64_t offset=0;
105 clock_t c=clock();
106 if (c<last)
107 offset+=int64_t(std::numeric_limits<unsigned>::max())-int64_t(std::numeric_limits<unsigned>::min());
108 last=c;
109 return offset+c;
110 }

◆ end()

void PMonUtils::CustomBenchmark::end ( int count = 1)
inline

Definition at line 73 of file CustomBenchmark.h.

74 {
75 assert(m_data_current);
76 m_data_current->count += count;
77 m_data_current->time_spent += clock_nooverflow() - m_data_current->time_at_begin;
79 }
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146

◆ getData()

void PMonUtils::CustomBenchmark::getData ( unsigned id,
uint64_t & count,
double & time_ms ) const
inline

Definition at line 81 of file CustomBenchmark.h.

82 {
83 assert(id<m_nmax);
84 Data * data = &(m_data[id]);
85 count = data->count;
86 time_ms = data->time_spent * (1000.0/CLOCKS_PER_SEC);
87 }
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11

◆ nMax()

unsigned PMonUtils::CustomBenchmark::nMax ( ) const
inline

Definition at line 42 of file CustomBenchmark.h.

42{ return m_nmax; }

◆ operator=()

CustomBenchmark & PMonUtils::CustomBenchmark::operator= ( const CustomBenchmark & )
private

◆ size()

unsigned PMonUtils::CustomBenchmark::size ( ) const
inline

Definition at line 43 of file CustomBenchmark.h.

43{ return m_nmax; }

Member Data Documentation

◆ m_data

Data* PMonUtils::CustomBenchmark::m_data
private

Definition at line 55 of file CustomBenchmark.h.

◆ m_data_current

Data* PMonUtils::CustomBenchmark::m_data_current
private

Definition at line 56 of file CustomBenchmark.h.

◆ m_nmax

const unsigned PMonUtils::CustomBenchmark::m_nmax
private

Definition at line 54 of file CustomBenchmark.h.


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