Fawkes API  Fawkes Development Version
fawkes::TimeTracker Class Reference

Time tracking utility. More...

#include <>>

Public Member Functions

 TimeTracker (const char *filename, bool add_default_class=false)
 Constructor for file logging. More...
 
 TimeTracker (bool add_default_class=false)
 Constructor. More...
 
 ~TimeTracker ()
 Destructor. More...
 
unsigned int add_class (std::string name)
 Add a new class. More...
 
void remove_class (unsigned int cls)
 Remove a class. More...
 
void ping (unsigned int cls)
 Ping class. More...
 
void ping_start (unsigned int cls)
 Start of given class task. More...
 
void ping_end (unsigned int cls)
 End of given class task. More...
 
void ping_abort (unsigned int cls)
 End of given class task without recording. More...
 
void ping (std::string comment="")
 Ping classless. More...
 
void reset (std::string comment="")
 Reset times. More...
 
void print_to_stdout ()
 Print results to stdout. More...
 
void print_to_file ()
 Print data to file suitable for gnuplot. More...
 

Static Public Attributes

static const unsigned int DEFAULT_CLASS = 0
 The default tracking class. More...
 

Detailed Description

Time tracking utility.

This class provides means to track time of different tasks in a process. You can assign an arbitrary number of tracking classes per object (although using a few classes is recommended for minimal influence of the measurement on the measured process). You can then print out averages and (max) deviation to get a feeling for the average performance and how flaky the runtimes are.

The time tracker can also be operated without any class if you only want to track a single process.

You can either just ping classless or a specific class which will then take the time difference between now and the last ping as the measured time. This is useful to determine the call frequency of a given item. If you want to benchmark sub-tasks you more likely want to start measuring at a specific point in time and then stop it after the sub-task is done to measure only this very task. This can be done by using pingStart() and pingEnd().

Author
Tim Niemueller

Definition at line 38 of file tracker.h.

Constructor & Destructor Documentation

◆ TimeTracker() [1/2]

fawkes::TimeTracker::TimeTracker ( const char *  filename,
bool  add_default_class = false 
)

Constructor for file logging.

Parameters
filenamename of the file to write log data to. File is overwritten.
add_default_classif true a default time class is added.

Definition at line 84 of file tracker.cpp.

◆ TimeTracker() [2/2]

fawkes::TimeTracker::TimeTracker ( bool  add_default_class = false)

Constructor.

Parameters
add_default_classif true a default time class is added.

Definition at line 68 of file tracker.cpp.

◆ ~TimeTracker()

fawkes::TimeTracker::~TimeTracker ( )

Destructor.

Definition at line 100 of file tracker.cpp.

Member Function Documentation

◆ add_class()

unsigned int fawkes::TimeTracker::add_class ( std::string  name)

Add a new class.

Adds a new class and gives the class ID.

Parameters
namename of the class
Returns
new class ID which is used for pinging this specific class.

Definition at line 156 of file tracker.cpp.

Referenced by TimeTrackerMainLoopThread::init(), FvRetrieverThread::init(), firevision::SiftClassifier::SiftClassifier(), firevision::SiftppClassifier::SiftppClassifier(), and firevision::SurfClassifier::SurfClassifier().

◆ ping() [1/2]

void fawkes::TimeTracker::ping ( unsigned int  cls)

Ping class.

This takes the time difference between now and the last ping and adds this to class cls.

Parameters
clsclass ID to ping

Definition at line 194 of file tracker.cpp.

◆ ping() [2/2]

void fawkes::TimeTracker::ping ( std::string  comment = "")

Ping classless.

This takes the time difference between now and the last ping and adds this to classless tracking.

Parameters
commentoptional ping comment.

Definition at line 138 of file tracker.cpp.

◆ ping_abort()

void fawkes::TimeTracker::ping_abort ( unsigned int  cls)

End of given class task without recording.

End the duration but do not take the time into the result measurements.

Parameters
clsclass ID to signal end of task

Definition at line 282 of file tracker.cpp.

◆ ping_end()

void fawkes::TimeTracker::ping_end ( unsigned int  cls)

◆ ping_start()

◆ print_to_file()

void fawkes::TimeTracker::print_to_file ( )

Print data to file suitable for gnuplot.

This will write the following data: average sec, average ms, average summed sec, deviation sec, deviation ms This data is generated for each class and concatenated into a single line and written to the file. A running number will be prepended as the first value. The data file is suitable as input for gnuplot.

Definition at line 442 of file tracker.cpp.

Referenced by TimeTrackerMainLoopThread::loop().

◆ print_to_stdout()

void fawkes::TimeTracker::print_to_stdout ( )

◆ remove_class()

void fawkes::TimeTracker::remove_class ( unsigned int  cls)

Remove a class.

This marks the class as unused. It is not longer possible to add times to this class but they will not be printed anymore. The space associated with this class is freed.

Parameters
clsID of the class to remove

Definition at line 174 of file tracker.cpp.

◆ reset()

void fawkes::TimeTracker::reset ( std::string  comment = "")

Reset times.

Reset tracker and set comment.

Parameters
commentcomment to set on tracker.

Definition at line 116 of file tracker.cpp.

Referenced by TimeTrackerMainLoopThread::loop().

Member Data Documentation

◆ DEFAULT_CLASS

const unsigned int fawkes::TimeTracker::DEFAULT_CLASS = 0
static

The default tracking class.

Optionally added in the constructor.

Definition at line 40 of file tracker.h.


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