Image Component Library (ICL)
Classes | Public Member Functions | Private Attributes | List of all members
icl::utils::StackTimer Class Reference

Tool for benchmarking method calls. More...

#include <StackTimer.h>

Classes

class  StackTimerNotifier
 StackTimerNotifier constructor, USE BENCHMARK_THIS_FUNCTION-MACRO instead. More...
 

Public Member Functions

 StackTimer (StackTimerNotifier *notifier)
 StackTimer constructor, USE BENCHMARK_THIS_FUNCTION-MACRO instead. More...
 
 ~StackTimer ()
 StackTimerNotifier destructor, USE BENCHMARK_THIS_FUNCTION-MACRO instead. More...
 

Private Attributes

Timerm_poTimer
 
StackTimerNotifierm_poNotifier
 

Detailed Description

Tool for benchmarking method calls.

The stack timer class is an Extension of the Timer class, that provides very convenient function benchmarking functionality. The only thing, a programmer needs to do, is to write the Macro BENCHMARK_THIS_FUNCTION at the beginning of the function(s), that should be benchmarked. The underlying implementation will then record each function call and execution time. At the end of the programm, the implicitly crated StackTimerNotifier will print the following information about the benchmarked function:

See also the following example:

    void funcion1(...){
       BENCHMARK_THIS_FUNCTION;
       ...
       ...
    }
    void funcion2(...){
       BENCHMARK_THIS_FUNCTION;
       ...
       ...
    }
    

At the end of the programm, the following info could be given to you:

    calls[     361]  time[ 77.7 ms]  avg[  215 us]  min[  183 us]  max[  5.2 ms] {function1}
    calls[     361]  time[  1.7 ms]  avg[    4 us]  min[    4 us]  max[   51 us] {function2}
    

s = seconds ms = milliseconds us = microseconds

Benchmarking code section

If sections of code shall be benchmarked, this can be done with the BENCHMARK_THIS_SECTION macro

int main(){
{
BENCHMARK_THIS_SECTION(first section);
// do something
}
{
BENCHMARK_THIS_SECTION(another section);
// do something
}
}

}

Constructor & Destructor Documentation

◆ StackTimer()

icl::utils::StackTimer::StackTimer ( StackTimerNotifier notifier)
inline

StackTimer constructor, USE BENCHMARK_THIS_FUNCTION-MACRO instead.

◆ ~StackTimer()

icl::utils::StackTimer::~StackTimer ( )
inline

StackTimerNotifier destructor, USE BENCHMARK_THIS_FUNCTION-MACRO instead.

Member Data Documentation

◆ m_poNotifier

StackTimerNotifier* icl::utils::StackTimer::m_poNotifier
private

◆ m_poTimer

Timer* icl::utils::StackTimer::m_poTimer
private

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