Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
BaseCounter Class Reference
Inheritance diagram for BaseCounter:
Inheritance graph
Collaboration diagram for BaseCounter:
Collaboration graph

Public Member Functions

 BaseCounter (const std::string &name, unsigned int secs)
 
bool operator() ()
 

Private Attributes

std::string name
 
unsigned int secs
 
bool started {false}
 
unsigned int count {0}
 
struct timespec t = {0, 0}
 

Static Private Attributes

static unsigned int columnWidth = 0
 

Constructor & Destructor Documentation

◆ BaseCounter()

BaseCounter::BaseCounter ( const std::string &  name,
unsigned int  secs 
)
108 : name(name_)
109 , secs(secs_)
110{
111 columnWidth = std::max(columnWidth, static_cast<unsigned int>(name_.length()));
112}
static unsigned int columnWidth
Definition measure-framerate-tests.cc:51
std::string name
Definition measure-framerate-tests.cc:45
unsigned int secs
Definition measure-framerate-tests.cc:46

Member Function Documentation

◆ operator()()

bool BaseCounter::operator() ( )
115{
116 if(!started && 0 == clock_gettime(CLOCK_REALTIME, &t))
117 {
118 started = true;
119 return true;
120 }
121
122 count++;
123
124 struct timespec now = {0, 0};
125 if(0 == clock_gettime(CLOCK_REALTIME, &now))
126 {
127 if(now.tv_sec > t.tv_sec + secs)
128 {
129 // We're done. Compute frequency.
130 double elapsed = now.tv_nsec - t.tv_nsec * 1e-9;
131 elapsed += now.tv_sec - t.tv_sec;
132 logger->info("{:{}}: {:10.2} Hz", name, columnWidth, count / elapsed);
133
134 return false;
135 }
136 }
137
138 return true;
139}
bool started
Definition measure-framerate-tests.cc:47
struct timespec t
Definition measure-framerate-tests.cc:49
unsigned int count
Definition measure-framerate-tests.cc:48
Scroom::Logger logger
Definition measure-framerate-tests.cc:24

Referenced by InvalidatingCounter::operator()().

Here is the caller graph for this function:

Member Data Documentation

◆ columnWidth

unsigned int BaseCounter::columnWidth = 0
staticprivate

Referenced by BaseCounter(), and operator()().

◆ count

unsigned int BaseCounter::count {0}
private
48{0};

Referenced by operator()().

◆ name

std::string BaseCounter::name
private

Referenced by operator()().

◆ secs

unsigned int BaseCounter::secs
private

Referenced by operator()().

◆ started

bool BaseCounter::started {false}
private
47{false};

Referenced by operator()().

◆ t

struct timespec BaseCounter::t = {0, 0}
private
49{0, 0};

Referenced by operator()().


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