#include <stattimer.hpp>
Public Member Functions | |
STimerRecords | calcStat (int i) |
STimerRecords | calcStat (const char *label) |
void | initTimeBuf (int i, int len) |
int | initTimeBuf (const char *label, int len) |
void | laptime (int i) |
int | laptime (const char *label) |
std::string | report (int i, STimerReporterFunc fn=NULL) |
std::string | report (const char *label, STimerReporterFunc fn=NULL) |
std::string | report (STimerReporterFunc fn=NULL) const |
void | setLabel (int i, const char *label) |
void | setReporterFunc (int i, STimerReporterFunc fn) |
int | setReporterFunc (const char *label, STimerReporterFunc fn) |
void | setReporterFunc (STimerReporterFunc fn) |
void | start (int i) |
int | start (const char *label) |
STimerList_ (int n, const STimerReporterFunc rfunc=reporterDefault, const std::string &outfile="") | |
STimerList_ (STimerReporterFunc const rfunc=reporterDefault, const std::string &outfile="") | |
void | stop (int i) |
int | stop (const char *label) |
~STimerList_ () | |
Static Public Member Functions | |
static std::string | reporterDefault (STimerRecords &rec) |
static std::string | reporterTSV (STimerRecords &rec) |
Class that contains and manages multiple timers.
This is designed as a template class just for testability (i.e. to cope with a mock subclass of STimer). Users should always use STimerList, which is typedef of STimerList_<STimer>.
Definition at line 70 of file stattimer.hpp.
|
inline |
Constructor that generates n timers.
n | [in] number of timers initially generated |
rfunc | [in] reporter function, which defaults to reporterDefault |
outfile | [in] output file name, which defaults to stdout |
Definition at line 219 of file stattimer.hpp.
|
inline |
Constructor that generates ntimer_default (= 20) timers.
rfunc | [in] reporter function, which defaults to reporterDefault |
outfile | [in] output file name, which defaults to stdout |
Definition at line 228 of file stattimer.hpp.
|
inline |
Destructor that calls report() and put the result to stdout.
Definition at line 234 of file stattimer.hpp.
|
inline |
Generate and return STimerRecords object of the timer whose id = i. If the timer i does not exist, it is automatically generated (and an empty records are returned). This may be useful when a user wants the statistics in a form other than string.
i | [in] Timer id |
Definition at line 468 of file stattimer.hpp.
|
inline |
Generate and return STimerRecords object of the timer with the specified label. See description of calcStat(i).
label | [in] Timer label |
Definition at line 481 of file stattimer.hpp.
|
inline |
Initialize the buffer to record recent values of elapsed time of the timer whose id = i. If the timer does not exist, it is automatially generated.
After this is called, the timer starts recording the elapsed time between each start() and stop() (or consecutive laptime()) in addition to updating the statistics data. Only the recent len values at most are preserved. The recorded values can be accessed in the STimerReporterFunc function as rec.timebuf vector.
i | [in] Timer id |
len | [in] Length of the buffer |
Definition at line 332 of file stattimer.hpp.
|
inline |
Initialize the buffer to record recent values of elapsed time of the timer with the specified label. See description of initTimeBuf(i, len).
label | [in] Timer label |
len | [in] Length of the buffer |
Definition at line 345 of file stattimer.hpp.
|
inline |
Record the lap time of the timer whose id = i. If the timer does not exist, it is automatially generated. It is equivalent to calling stop(i) followed by start(i) with zero delay.
i | [in] Timer id |
Definition at line 299 of file stattimer.hpp.
|
inline |
Record the lap time of the timer with the specified label. See description of laptime(int).
label | [in] Timer label |
Definition at line 311 of file stattimer.hpp.
|
inline |
Generate the report of the timer i and return it as string. Reporter function to be used can optionally be specified. If the timer i does not exist, it is automatically generated (and an empty string is reported).
i | [in] Timer id |
fn | [in] Reporter function. If not specified, the function set by setReporterFunc is used. |
Definition at line 424 of file stattimer.hpp.
|
inline |
Generate the report of the timer with the specified label and return it as string. See description of report(i, fn).
label | [in] Timer label |
fn | [in] Reporter function. If not specified, the function set by setReporterFunc is used. |
Definition at line 437 of file stattimer.hpp.
|
inline |
Generate the reports of all the timer and return the concatenated string of the reports. Reporter function to be used can optionally be specified.
fn | [in] Reporter function. If not specified, the function set by setReporterFunc is used for each timer. |
Definition at line 450 of file stattimer.hpp.
|
inlinestatic |
Definition at line 488 of file stattimer.hpp.
|
inlinestatic |
Definition at line 505 of file stattimer.hpp.
|
inline |
Set the label to the timer whose id = i. If the same label already exists (for another timer), that old label is cleared in advance. If the timer i does not exist, it is automatically generated. If the timer i already has a label, the old label is cleared in advance.
i | [in] Timer id to which the label is set. |
label | [in] Timer label |
Definition at line 360 of file stattimer.hpp.
|
inline |
Set the reporter function to the timer i. If the timer does not exist, it is automatially generated. The reporter functions of the other timers are unchanged.
i | [in] Timer id to which the reporter function is associated |
fn | [in] Reporter function. When fn = NULL, nothing is reported. |
Definition at line 382 of file stattimer.hpp.
|
inline |
Set the reporter function to the timer specified with the label. If the timer does not exist, it is automatially generated. The reporter functions of the other timers are unchanged.
label | [in] Label of the timer to which the reporter function is associated |
fn | [in] Reporter function. When fn = NULL, nothing is reported. |
Definition at line 395 of file stattimer.hpp.
|
inline |
Set the reporter function to all the timers. This reporter function is also applied to the timers that will be generated in future.
fn | [in] Reporter function. When fn = NULL, nothing is reported. |
Definition at line 407 of file stattimer.hpp.
|
inline |
Start the timer whose id = i. If the timer does not exist, it is automatially generated.
i | [in] Timer id |
Definition at line 249 of file stattimer.hpp.
|
inline |
Start the timer with the specified label. If the timer does not exist, it is automatially generated.
label | [in] Timer label |
Definition at line 260 of file stattimer.hpp.
|
inline |
Stop the timer whose id = i and update the statistics record. If the timer has not been started, nothing is done. If the timer does not exist, it is automatially generated (and of course nothing is recorded).
i | [in] Timer id |
Definition at line 274 of file stattimer.hpp.
|
inline |
Stop the timer with the specified label. See description of stop(int).
label | [in] Timer label |
Definition at line 286 of file stattimer.hpp.