Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BIAS::TimeMeasure Class Reference

class TimeMeasure contains functions for timing real time and cpu time. More...

#include <Base/Debug/TimeMeasure.hh>

+ Collaboration diagram for BIAS::TimeMeasure:

Public Member Functions

void CloseTimerFile ()
 
double GetCycleCount () const
 return number of cycles between all subsequent calls to Start() and Stop() since last call to Reset() More...
 
double GetFreq () const
 returns the frequency in Hz based on real time (= fps) More...
 
double GetIdleTime () const
 WIN32: return time that system spended in idle mode in msec cmenk Seems to be a bit useless. More...
 
double GetKernelTime () const
 WIN32: return time that system spended in kernel mode in msec cmenk = Sum over all processes on all processors in kernel mode (!!!including the system idle process!!!) More...
 
double GetRealTime () const
 return real time (=wall time clock) in usec JW For Win32: real-time is measured differently from user-/kernel-time. More...
 
double GetUserFreq () const
 returns the frequency in Hz based on user time (= fps) More...
 
double GetUserTime () const
 return user time (=system usage time) in msec JW For Win32: user-time is the sum over all processes on all processors in user-mode (not only the calling process!) More...
 
bool IsRunning () const
 
void LogToFileAndReset (const std::string &comment)
 
double MeasureOverhead ()
 returns the number of cycles between subsequent Start() and Stop() calls !! implies a Reset(); !!! More...
 
double MeasureProcessorFrequency ()
 measures the ProcessorFrequency in MHz More...
 
void Print (std::ostream &os=std::cout) const
 
void PrintCycleCount (std::ostream &os=std::cout) const
 prints the number of cycles between subsequent calls to Start() and Stop() since last call to Reset() to os More...
 
void PrintIdleTime (std::ostream &os=std::cout, const bool &verbose=true) const
 print the time that the system spended in idle mode More...
 
void PrintKernelTime (std::ostream &os=std::cout, const bool &verbose=true) const
 print the time that the system spended in kernel mode (WIN32) More...
 
void PrintRealTime (std::ostream &os=std::cout, const bool &verbose=true) const
 print the real time (=wall time clok) More...
 
void PrintUserTime (std::ostream &os=std::cout, const bool &verbose=true) const
 print the user time (=system usage time) More...
 
void ReadCycleCounter (unsigned int *hi, unsigned int *lo)
 
void Reset ()
 
void SetTimerFile (const std::string &file)
 
void Start ()
 
void Stop ()
 
 TimeMeasure ()
 default constructor: More...
 
 ~TimeMeasure ()
 print the output when the desctructor is called ? More...
 

Static Public Member Functions

static std::string GetCurrentTimeAsString ()
 Obtains the current time and returns as string. More...
 
static std::string GetDateAsString ()
 Obtains the current date and returns as string. More...
 
static void MSecondsToHumanReadable (const unsigned long &msIN, int &msecOUT, int &seconds, int &minutes, int &hours, int &days, int &weeks)
 converts a given amount of millisecs to human redable format More...
 
static std::ostream & PrintMsecHumanReadable (const unsigned long msecIN, std::ostream &os=std::cout)
 display nr of msecs in format weeks,days,hours,minutes,seconds More...
 

Protected Attributes

double _dSum
 
timeval rtActual
 
timeval rtKernelSum
 
timeval rtLast
 
timeval rtRealSum
 
bool running
 
struct tms startstruct stopstruct
 
clock_t user
 

Static Protected Attributes

static std::ofstream TimerStream_
 

Detailed Description

class TimeMeasure contains functions for timing real time and cpu time.

added Win32 rdtsc assembler cycle count with int64 jw 12/2004 added Linux cycle count functions for i386-processors woelk 07/2003

For Win32 the minimum requiered version is 0x0501 (WinXP/Server2005)

Author
Jan Woetzel (03/04/2002 - 11/2005)
Examples:
ExampleBilateral.cpp, ExampleBinomial.cpp, ExampleContourDetectorSimple.cpp, ExampleCylinderMapping.cpp, ExampleDeInterlace.cpp, ExampleDirectToDisk.cpp, ExampleFFT2D.cpp, ExampleFFT2D_free.cpp, ExampleFMT2D.cpp, ExampleGauss.cpp, ExampleGradient.cpp, ExampleHarrisColor.cpp, ExampleHomographyMapping.cpp, ExampleLapack.cpp, ExampleLineMatcher.cpp, ExampleLogPolarMapping.cpp, ExampleMultipleDepthWarp.cpp, ExampleParabola.cpp, ExampleProjectionMapping.cpp, ExamplePtGreyHiresColor.cpp, ExamplePyramidImage.cpp, ExampleRandom.cpp, ExampleRemoveSaltAndPepper.cpp, ExampleRescale.cpp, ExampleSVD.cpp, ExampleTimeMeasureCycle.cpp, ExampleTracker.cpp, ExampleTrackerBase.cpp, ExampleTriangulateOptimal.cpp, ExampleUpsampleBy2Grey.cpp, ExampleVideoServer.cpp, and InvestigateEpipoleEstimation.cpp.

Definition at line 111 of file TimeMeasure.hh.

Constructor & Destructor Documentation

TimeMeasure::TimeMeasure ( )

default constructor:

Definition at line 16 of file TimeMeasure.cpp.

BIAS::TimeMeasure::~TimeMeasure ( )
inline

print the output when the desctructor is called ?

Definition at line 118 of file TimeMeasure.hh.

Member Function Documentation

void TimeMeasure::CloseTimerFile ( )

Definition at line 338 of file TimeMeasure.cpp.

std::string TimeMeasure::GetCurrentTimeAsString ( )
static

Obtains the current time and returns as string.

For alternative formats see: http://www.cplusplus.com/reference/clibrary/ctime/strftime/

Author
Ingo Schiller
Date
04/2011

Definition at line 211 of file TimeMeasure.cpp.

double TimeMeasure::GetCycleCount ( ) const
std::string TimeMeasure::GetDateAsString ( )
static

Obtains the current date and returns as string.

For alternative formats see: http://www.cplusplus.com/reference/clibrary/ctime/strftime/

Author
Ingo Schiller
Date
04/2011

Definition at line 224 of file TimeMeasure.cpp.

double TimeMeasure::GetFreq ( ) const

returns the frequency in Hz based on real time (= fps)

Definition at line 405 of file TimeMeasure.cpp.

double TimeMeasure::GetIdleTime ( ) const

WIN32: return time that system spended in idle mode in msec cmenk Seems to be a bit useless.

Definition at line 396 of file TimeMeasure.cpp.

double TimeMeasure::GetKernelTime ( ) const

WIN32: return time that system spended in kernel mode in msec cmenk = Sum over all processes on all processors in kernel mode (!!!including the system idle process!!!)

Definition at line 387 of file TimeMeasure.cpp.

double TimeMeasure::GetRealTime ( ) const

return real time (=wall time clock) in usec JW For Win32: real-time is measured differently from user-/kernel-time.

Don't wonder about small inconsistancies!

Examples:
ExampleCylinderMapping.cpp, ExampleDirectToDisk.cpp, ExampleFFT2D.cpp, ExampleFFT2D_free.cpp, ExampleLapack.cpp, ExampleMultipleDepthWarp.cpp, ExamplePyramidImage.cpp, ExampleRandom.cpp, ExampleSVD.cpp, ExampleTracker.cpp, ExampleTrackerBase.cpp, ExampleTriangulateOptimal.cpp, ExampleUpsampleBy2Grey.cpp, and ExampleVideoServer.cpp.

Definition at line 370 of file TimeMeasure.cpp.

Referenced by BIAS::CornerDetectorGradient< StorageType, CalculationType >::_EnforceMinimumDistance(), BIAS::StructureTensor< InputStorageType, OutputStorageType >::CalcStructureTensor5x5(), BIAS::StructureTensor< InputStorageType, OutputStorageType >::CalcStructureTensor7x7(), BIAS::Condensation::CalculateBaseWeights_(), BIAS::Condensation::CalculateMean_(), BIAS::CornerDetectorGradient< StorageType, CalculationType >::Detect(), BIAS::GrabMasterThread::Entry(), BIAS::TrackerBaseInterface< StorageType >::EvaluateResult_(), BIAS::VideoSource_Disk_Bayer::GrabSingle(), BIAS::VideoSource_Disk::GrabSingle(), BIAS::Condensation::InitPrior(), BIAS::Condensation::PredictNewSamplePositions(), BIAS::Tracker< StorageType, CalculationType >::PreparePyramide(), BIAS::Condensation::Process(), BIAS::TrackerBaseInterface< StorageType >::RejectX84_(), BIAS::TrackerBaseInterface< StorageType >::Track(), BIAS::Tracker< StorageType, CalculationType >::Track(), BIAS::TrackerBaseSimple< StorageType >::Track_(), BIAS::TrackerBaseWeighted1D< StorageType >::Track_(), and BIAS::TrackerBaseWeighted< StorageType >::Track_().

double TimeMeasure::GetUserFreq ( ) const

returns the frequency in Hz based on user time (= fps)

Definition at line 410 of file TimeMeasure.cpp.

double TimeMeasure::GetUserTime ( ) const

return user time (=system usage time) in msec JW For Win32: user-time is the sum over all processes on all processors in user-mode (not only the calling process!)

Examples:
ExampleFMT2D.cpp, ExampleHomographyMapping.cpp, ExampleLapack.cpp, ExampleLineMatcher.cpp, ExampleLogPolarMapping.cpp, ExampleParabola.cpp, ExampleProjectionMapping.cpp, and ExampleUpsampleBy2Grey.cpp.

Definition at line 376 of file TimeMeasure.cpp.

Referenced by BIAS::Render_().

bool TimeMeasure::IsRunning ( ) const

Definition at line 415 of file TimeMeasure.cpp.

void TimeMeasure::LogToFileAndReset ( const std::string &  comment)

Definition at line 358 of file TimeMeasure.cpp.

double TimeMeasure::MeasureOverhead ( )

returns the number of cycles between subsequent Start() and Stop() calls !! implies a Reset(); !!!

Author
woelk

Definition at line 239 of file TimeMeasure.cpp.

double TimeMeasure::MeasureProcessorFrequency ( )

measures the ProcessorFrequency in MHz

Author
woelk

Definition at line 255 of file TimeMeasure.cpp.

void TimeMeasure::MSecondsToHumanReadable ( const unsigned long &  msIN,
int &  msecOUT,
int &  seconds,
int &  minutes,
int &  hours,
int &  days,
int &  weeks 
)
static

converts a given amount of millisecs to human redable format

extracts hours, minutes, seconds, msecs from amout of msecs (1/1000 sec).

Parameters
msecINinput parameter
Author
Jan Woetzel

Definition at line 144 of file TimeMeasure.cpp.

void TimeMeasure::Print ( std::ostream &  os = std::cout) const
void TimeMeasure::PrintCycleCount ( std::ostream &  os = std::cout) const

prints the number of cycles between subsequent calls to Start() and Stop() since last call to Reset() to os

Author
woelk
Examples:
ExampleTimeMeasureCycle.cpp.

Definition at line 330 of file TimeMeasure.cpp.

void TimeMeasure::PrintIdleTime ( std::ostream &  os = std::cout,
const bool &  verbose = true 
) const

print the time that the system spended in idle mode

Parameters
verbosetrue for additionoutput in days hour sminutes seconds cmenk

Definition at line 316 of file TimeMeasure.cpp.

void TimeMeasure::PrintKernelTime ( std::ostream &  os = std::cout,
const bool &  verbose = true 
) const

print the time that the system spended in kernel mode (WIN32)

Parameters
verbosetrue for additionoutput in days hour sminutes seconds cmenk

Definition at line 302 of file TimeMeasure.cpp.

std::ostream & TimeMeasure::PrintMsecHumanReadable ( const unsigned long  msecIN,
std::ostream &  os = std::cout 
)
static

display nr of msecs in format weeks,days,hours,minutes,seconds

Definition at line 178 of file TimeMeasure.cpp.

void TimeMeasure::PrintRealTime ( std::ostream &  os = std::cout,
const bool &  verbose = true 
) const

print the real time (=wall time clok)

Parameters
verbosetrue for additionoutput in days hour sminutes seconds Jan Woetzel
Examples:
ExampleContourDetectorSimple.cpp, and ExampleRemoveSaltAndPepper.cpp.

Definition at line 273 of file TimeMeasure.cpp.

Referenced by BIAS::PMDWarp::Draw().

void TimeMeasure::PrintUserTime ( std::ostream &  os = std::cout,
const bool &  verbose = true 
) const

print the user time (=system usage time)

Parameters
verbosetrue for additionoutput in days hour sminutes seconds Jan Woetzel

Definition at line 287 of file TimeMeasure.cpp.

void BIAS::TimeMeasure::ReadCycleCounter ( unsigned int *  hi,
unsigned int *  lo 
)
inline

Referenced by Start(), and Stop().

void TimeMeasure::Reset ( )
void TimeMeasure::SetTimerFile ( const std::string &  file)

Definition at line 345 of file TimeMeasure.cpp.

void BIAS::TimeMeasure::Start ( )
inline
Examples:
ExampleBinomial.cpp, ExampleContourDetectorSimple.cpp, ExampleCylinderMapping.cpp, ExampleDeInterlace.cpp, ExampleDirectToDisk.cpp, ExampleFFT2D.cpp, ExampleFFT2D_free.cpp, ExampleFMT2D.cpp, ExampleGauss.cpp, ExampleGradient.cpp, ExampleHomographyMapping.cpp, ExampleLapack.cpp, ExampleLineMatcher.cpp, ExampleLogPolarMapping.cpp, ExampleMultipleDepthWarp.cpp, ExampleParabola.cpp, ExampleProjectionMapping.cpp, ExamplePyramidImage.cpp, ExampleRandom.cpp, ExampleRemoveSaltAndPepper.cpp, ExampleRescale.cpp, ExampleSVD.cpp, ExampleTimeMeasureCycle.cpp, ExampleTracker.cpp, ExampleTrackerBase.cpp, ExampleTriangulateOptimal.cpp, ExampleUpsampleBy2Grey.cpp, and ExampleVideoServer.cpp.

Definition at line 294 of file TimeMeasure.hh.

References ReadCycleCounter(), rtLast, and running.

Referenced by BIAS::CornerDetectorGradient< StorageType, CalculationType >::_EnforceMinimumDistance(), BIAS::MixtureOfGaussians< StorageType >::Apply(), BIAS::StructureTensor< InputStorageType, OutputStorageType >::CalcStructureTensor5x5(), BIAS::StructureTensor< InputStorageType, OutputStorageType >::CalcStructureTensor7x7(), BIAS::Condensation::CalculateBaseWeights_(), BIAS::Condensation::CalculateMean_(), BIAS::CornerDetectorGradient< StorageType, CalculationType >::Detect(), BIAS::PMDWarp::Draw(), BIAS::GrabMasterThread::Entry(), BIAS::TrackerBaseInterface< StorageType >::EvaluateResult_(), BIAS::IntegralHistogram::GenerateIntegralHistDiffBin(), BIAS::GrabMasterThread::GrabMasterThread(), BIAS::VideoSource_Disk_Bayer::GrabSingle(), BIAS::VideoSource_Disk::GrabSingle(), BIAS::Condensation::InitPrior(), BIAS::Condensation::PredictNewSamplePositions(), BIAS::VideoSource_Disk::PreGrab(), BIAS::Tracker< StorageType, CalculationType >::PreparePyramide(), BIAS::Condensation::Process(), BIAS::TrackerBaseInterface< StorageType >::RejectX84_(), BIAS::Render_(), BIAS::TimeMeasurement::Start(), BIAS::TrackerBaseInterface< StorageType >::Track(), BIAS::Tracker< StorageType, CalculationType >::Track(), and BIAS::TrackerBaseSimple< StorageType >::Track_().

void BIAS::TimeMeasure::Stop ( )
inline
Examples:
ExampleBinomial.cpp, ExampleContourDetectorSimple.cpp, ExampleCylinderMapping.cpp, ExampleDeInterlace.cpp, ExampleDirectToDisk.cpp, ExampleFFT2D.cpp, ExampleFFT2D_free.cpp, ExampleFMT2D.cpp, ExampleGauss.cpp, ExampleGradient.cpp, ExampleHomographyMapping.cpp, ExampleLapack.cpp, ExampleLineMatcher.cpp, ExampleLogPolarMapping.cpp, ExampleMultipleDepthWarp.cpp, ExampleParabola.cpp, ExampleProjectionMapping.cpp, ExamplePyramidImage.cpp, ExampleRandom.cpp, ExampleRemoveSaltAndPepper.cpp, ExampleRescale.cpp, ExampleSVD.cpp, ExampleTimeMeasureCycle.cpp, ExampleTracker.cpp, ExampleTrackerBase.cpp, ExampleTriangulateOptimal.cpp, ExampleUpsampleBy2Grey.cpp, and ExampleVideoServer.cpp.

Definition at line 312 of file TimeMeasure.hh.

References _dSum, ReadCycleCounter(), rtActual, rtLast, rtRealSum, running, stopstruct, and user.

Referenced by BIAS::CornerDetectorGradient< StorageType, CalculationType >::_EnforceMinimumDistance(), BIAS::MixtureOfGaussians< StorageType >::Apply(), BIAS::StructureTensor< InputStorageType, OutputStorageType >::CalcStructureTensor5x5(), BIAS::StructureTensor< InputStorageType, OutputStorageType >::CalcStructureTensor7x7(), BIAS::Condensation::CalculateBaseWeights_(), BIAS::Condensation::CalculateMean_(), BIAS::CornerDetectorGradient< StorageType, CalculationType >::Detect(), BIAS::PMDWarp::Draw(), BIAS::GrabMasterThread::Entry(), BIAS::TrackerBaseInterface< StorageType >::EvaluateResult_(), BIAS::IntegralHistogram::GenerateIntegralHistDiffBin(), BIAS::VideoSource_Disk_Bayer::GrabSingle(), BIAS::VideoSource_Disk::GrabSingle(), BIAS::Condensation::InitPrior(), BIAS::Condensation::PredictNewSamplePositions(), BIAS::Tracker< StorageType, CalculationType >::PreparePyramide(), BIAS::Condensation::Process(), BIAS::TrackerBaseInterface< StorageType >::RejectX84_(), BIAS::Render_(), BIAS::TrackerBaseInterface< StorageType >::Track(), BIAS::Tracker< StorageType, CalculationType >::Track(), BIAS::TrackerBaseSimple< StorageType >::Track_(), BIAS::TrackerBaseWeighted1D< StorageType >::Track_(), BIAS::TrackerBaseWeighted< StorageType >::Track_(), and BIAS::TimeMeasurement::~TimeMeasurement().

Member Data Documentation

double BIAS::TimeMeasure::_dSum
protected

Definition at line 273 of file TimeMeasure.hh.

Referenced by Stop().

timeval BIAS::TimeMeasure::rtActual
protected

Definition at line 259 of file TimeMeasure.hh.

Referenced by Stop().

timeval BIAS::TimeMeasure::rtKernelSum
protected

Definition at line 260 of file TimeMeasure.hh.

timeval BIAS::TimeMeasure::rtLast
protected

Definition at line 258 of file TimeMeasure.hh.

Referenced by Start(), and Stop().

timeval BIAS::TimeMeasure::rtRealSum
protected

Definition at line 257 of file TimeMeasure.hh.

Referenced by Stop().

bool BIAS::TimeMeasure::running
protected

Definition at line 263 of file TimeMeasure.hh.

Referenced by Start(), and Stop().

struct tms startstruct BIAS::TimeMeasure::stopstruct
protected

Definition at line 262 of file TimeMeasure.hh.

Referenced by Stop().

std::ofstream BIAS::TimeMeasure::TimerStream_
staticprotected

Definition at line 284 of file TimeMeasure.hh.

clock_t BIAS::TimeMeasure::user
protected

Definition at line 261 of file TimeMeasure.hh.

Referenced by Stop().


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