# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CHTimer Class Reference

Hierarchical timing system. More...

#include <hierarchical_timer.h>

List of all members.

Public Types

enum  TSortCriterion {
  NoSort, TotalTime, TotalTimeWithoutSons, MeanTime,
  NumVisits, MaxTime, MinTime, SortCriterionsLast
}

Public Methods

 CHTimer (const char *name, bool isRoot=false)
 ctor. More...

void before ()
 Starts a measuring session. More...

void after (bool displayAfter=false)
const char * getName () const

Static Public Methods

void startBench (bool wantStandardDeviation=false, bool quick=false)
 Starts a bench session. More...

void bench ()
 For backward compatibility. More...

void adjust ()
 For backward compatibility. More...

void endBench ()
 Ends a bench session. More...

void display (CLog *log=InfoLog, TSortCriterion criterion=TotalTime, bool displayInline=true, bool displayEx=true)
 Display results. More...

void displayByExecutionPath (CLog *log=InfoLog, TSortCriterion criterion=TotalTime, bool displayInline=true, bool alignPaths=true, bool displayEx=true)
 Display results by execution paths. More...

void displayHierarchical (CLog *log=InfoLog, bool displayEx=true, uint labelNumChar=32, uint indentationStep=2)
 Hierarchical display, no sorting is done. More...

void displayHierarchicalByExecutionPath (CLog *log=InfoLog, bool displayEx=true, uint labelNumChar=32, uint indentationStep=2)
 Hierarchical display, no sorting is done. More...

void displayHierarchicalByExecutionPathSorted (CLog *log=InfoLog, TSortCriterion criterion=TotalTime, bool displayEx=true, uint labelNumChar=32, uint indentationStep=2)
 Hierarchical display, sorting is done in branchs. More...

void clear ()
 Clears stats, and reinits all timer structure. More...


Private Types

typedef std::vector< CNode * > TNodeVect
typedef std::vector< CHTimer * > TTimerVect

Private Methods

void walkTreeToCurrent ()

Private Attributes

const char * _Name
CHTimer * _Parent
TTimerVect _Sons
bool _IsRoot

Static Private Attributes

CNode _RootNode
CNode_CurrNode = &_RootNode
CHTimer _RootTimer
CSimpleClock _PreambuleClock
 This clock is used to measure the preambule of methods such as CHTimer::before() This is static, but the Hierarchical Timer doesn't support multithreading anyway.. More...

double _MsPerTick
bool _Benching = false
bool _BenchStartedOnce = false
bool _WantStandardDeviation = false
CHTimer * _CurrTimer = &_RootTimer


Detailed Description

Hierarchical timing system.

Allows to accurately measure performance of routines, and displays results hierarchically. To time a piece of code, just declare a static CHTimer object and encapsulate code between calls to before() and after() methods. ex:

 void myFunction()
 {
        static CHTimer  myTimer("myFunction");
        myTimer.before();
        // some code here
        myTimer.after();
 }
 *
Don't forget to call after() to avoid timing wrongness or assertion crashes !

Warning:
Supports only single-threaded applications.
Supports only Intel processors.
Author:
Benjamin Legros , Nicolas Vizerie , Nevrax France
Date:
2001, 2002

Definition at line 205 of file hierarchical_timer.h.


Member Typedef Documentation

typedef std::vector<CNode *> NLMISC::CHTimer::TNodeVect [private]
 

Definition at line 283 of file hierarchical_timer.h.

Referenced by display, displayByExecutionPath, and displayHierarchical.

typedef std::vector<CHTimer *> NLMISC::CHTimer::TTimerVect [private]
 

Definition at line 284 of file hierarchical_timer.h.


Member Enumeration Documentation

enum NLMISC::CHTimer::TSortCriterion
 

Enumeration values:
NoSort 
TotalTime 
TotalTimeWithoutSons 
MeanTime 
NumVisits 
MaxTime 
MinTime 
SortCriterionsLast 

Definition at line 209 of file hierarchical_timer.h.


Constructor & Destructor Documentation

NLMISC::CHTimer::CHTimer const char *    name,
bool    isRoot = false
[inline]
 

ctor.

Definition at line 220 of file hierarchical_timer.h.

References _IsRoot, and _Name.

Referenced by NLMISC::CHTimer::CNode::CNode, and displayHierarchical.


Member Function Documentation

void NLMISC::CHTimer::adjust   [inline, static]
 

For backward compatibility.

Definition at line 237 of file hierarchical_timer.h.

void NLMISC::CHTimer::after bool    displayAfter = false
 

Definition at line 827 of file hierarchical_timer.cpp.

References _Benching, _CurrNode, _CurrTimer, _MsPerTick, _Name, _Parent, _PreambuleClock, NLMISC::CHTimer::CNode::Clock, NLMISC::CHTimer::CNode::LastSonsTotalTime, NLMISC::CHTimer::CNode::MaxTime, NLMISC::CHTimer::CNode::Measures, min, NLMISC::CHTimer::CNode::MinTime, nlinfo, NLMISC::CHTimer::CNode::NumVisits, NLMISC::CHTimer::CNode::Parent, NLMISC::CHTimer::CNode::SonsPreambule, NLMISC::CHTimer::CNode::SonsTotalTime, and NLMISC::CHTimer::CNode::TotalTime.

void NLMISC::CHTimer::before  
 

Starts a measuring session.

Definition at line 804 of file hierarchical_timer.cpp.

References _Benching, _CurrNode, _CurrTimer, _Parent, _PreambuleClock, NLMISC::CHTimer::CNode::Clock, NLMISC::CHTimer::CNode::NumVisits, NLMISC::CHTimer::CNode::Parent, NLMISC::CHTimer::CNode::SonsPreambule, and walkTreeToCurrent.

void NLMISC::CHTimer::bench   [inline, static]
 

For backward compatibility.

Definition at line 234 of file hierarchical_timer.h.

References startBench.

void NLMISC::CHTimer::clear   [static]
 

Clears stats, and reinits all timer structure.

Definition at line 668 of file hierarchical_timer.cpp.

References _CurrNode, _RootNode, nlassert, NLMISC::CHTimer::CNode::releaseSons, and NLMISC::CHTimer::CNode::reset.

Referenced by startBench.

void NLMISC::CHTimer::display CLog   log = InfoLog,
TSortCriterion    criterion = TotalTime,
bool    displayInline = true,
bool    displayEx = true
[static]
 

Display results.

Parameters:
displayEx  true to display more detailed infos

Definition at line 284 of file hierarchical_timer.cpp.

References _BenchStartedOnce, _CurrNode, _MsPerTick, _RootNode, _WantStandardDeviation, format, NoSort, NLMISC::smprintf, NLMISC::CHTimer::CNode::SonsPreambule, TNodeVect, and NLMISC::toString.

void NLMISC::CHTimer::displayByExecutionPath CLog   log = InfoLog,
TSortCriterion    criterion = TotalTime,
bool    displayInline = true,
bool    alignPaths = true,
bool    displayEx = true
[static]
 

Display results by execution paths.

Parameters:
displayInline  true to display each result on a single line.
alignPaths  true to display all execution paths aligned.
displayEx  true to display more detailed infos.

Definition at line 371 of file hierarchical_timer.cpp.

References _BenchStartedOnce, _CurrNode, _MsPerTick, _RootNode, _WantStandardDeviation, format, NLMISC::CHTimer::CNode::getNumNodes, nlassert, NoSort, NLMISC::smprintf, NLMISC::CHTimer::CNode::SonsPreambule, TNodeVect, and NLMISC::toString.

void NLMISC::CHTimer::displayHierarchical CLog   log = InfoLog,
bool    displayEx = true,
uint    labelNumChar = 32,
uint    indentationStep = 2
[static]
 

Hierarchical display, no sorting is done.

Parameters:
displayEx  true to display more detailed infos.
labelNumChar 

Definition at line 468 of file hierarchical_timer.cpp.

References _BenchStartedOnce, _CurrNode, _MsPerTick, _RootNode, _RootTimer, _WantStandardDeviation, CHTimer, depth, min, nlassert, NLMISC::CHTimer::CNode::SonsPreambule, and TNodeVect.

void NLMISC::CHTimer::displayHierarchicalByExecutionPath CLog   log = InfoLog,
bool    displayEx = true,
uint    labelNumChar = 32,
uint    indentationStep = 2
[static]
 

Hierarchical display, no sorting is done.

Parameters:
displayEx  true to display more detailed infos.
labelNumChar 

Definition at line 542 of file hierarchical_timer.cpp.

References displayHierarchicalByExecutionPathSorted, and NoSort.

void NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted CLog   log = InfoLog,
TSortCriterion    criterion = TotalTime,
bool    displayEx = true,
uint    labelNumChar = 32,
uint    indentationStep = 2
[static]
 

Hierarchical display, sorting is done in branchs.

Parameters:
displayEx  true to display more detailed infos.
labelNumChar 

Definition at line 549 of file hierarchical_timer.cpp.

References _BenchStartedOnce, _CurrNode, _MsPerTick, _RootNode, _WantStandardDeviation, min, nlassert, NoSort, and NLMISC::CHTimer::CNode::SonsPreambule.

Referenced by displayHierarchicalByExecutionPath.

void NLMISC::CHTimer::endBench   [static]
 

Ends a bench session.

Definition at line 267 of file hierarchical_timer.cpp.

References _Benching, _CurrNode, _RootNode, _RootTimer, and nlwarning.

const char* NLMISC::CHTimer::getName   const [inline]
 

Definition at line 226 of file hierarchical_timer.h.

References _Name.

void NLMISC::CHTimer::startBench bool    wantStandardDeviation = false,
bool    quick = false
[static]
 

Starts a bench session.

Parameters:
wantStandardDeviation  When true, benchs will report the standard deviation of values. This require more memory, howeve, because each samples must be kept.
quick  if true, quick compute the frequency of the processor

Definition at line 247 of file hierarchical_timer.cpp.

References _Benching, _BenchStartedOnce, _MsPerTick, _RootNode, _RootTimer, _WantStandardDeviation, clear, nlassert, and NLMISC::CHTimer::CNode::Owner.

Referenced by bench.

void NLMISC::CHTimer::walkTreeToCurrent   [private]
 

Definition at line 166 of file hierarchical_timer.cpp.

References _CurrNode, and NLMISC::CHTimer::CNode::Sons.

Referenced by before.


Member Data Documentation

bool NLMISC::CHTimer::_Benching = false [static, private]
 

Definition at line 51 of file hierarchical_timer.cpp.

Referenced by after, before, endBench, and startBench.

bool NLMISC::CHTimer::_BenchStartedOnce = false [static, private]
 

Definition at line 52 of file hierarchical_timer.cpp.

Referenced by display, displayByExecutionPath, displayHierarchical, displayHierarchicalByExecutionPathSorted, and startBench.

CHTimer::CNode * NLMISC::CHTimer::_CurrNode = &_RootNode [static, private]
 

Definition at line 48 of file hierarchical_timer.cpp.

Referenced by after, before, clear, display, displayByExecutionPath, displayHierarchical, displayHierarchicalByExecutionPathSorted, endBench, and walkTreeToCurrent.

CHTimer * NLMISC::CHTimer::_CurrTimer = &_RootTimer [static, private]
 

Definition at line 55 of file hierarchical_timer.cpp.

Referenced by after, and before.

bool NLMISC::CHTimer::_IsRoot [private]
 

Definition at line 416 of file hierarchical_timer.h.

Referenced by CHTimer.

double NLMISC::CHTimer::_MsPerTick [static, private]
 

Definition at line 53 of file hierarchical_timer.cpp.

Referenced by after, display, displayByExecutionPath, displayHierarchical, displayHierarchicalByExecutionPathSorted, and startBench.

const char* NLMISC::CHTimer::_Name [private]
 

Definition at line 410 of file hierarchical_timer.h.

Referenced by after, CHTimer, and getName.

CHTimer* NLMISC::CHTimer::_Parent [private]
 

Definition at line 412 of file hierarchical_timer.h.

Referenced by after, and before.

CSimpleClock NLMISC::CHTimer::_PreambuleClock [static, private]
 

This clock is used to measure the preambule of methods such as CHTimer::before() This is static, but the Hierarchical Timer doesn't support multithreading anyway..

Definition at line 49 of file hierarchical_timer.cpp.

Referenced by after, and before.

CHTimer::CNode NLMISC::CHTimer::_RootNode [static, private]
 

Definition at line 47 of file hierarchical_timer.cpp.

Referenced by clear, display, displayByExecutionPath, displayHierarchical, displayHierarchicalByExecutionPathSorted, endBench, and startBench.

CHTimer NLMISC::CHTimer::_RootTimer [static, private]
 

Referenced by displayHierarchical, endBench, and startBench.

TTimerVect NLMISC::CHTimer::_Sons [private]
 

Definition at line 414 of file hierarchical_timer.h.

bool NLMISC::CHTimer::_WantStandardDeviation = false [static, private]
 

Definition at line 54 of file hierarchical_timer.cpp.

Referenced by display, displayByExecutionPath, displayHierarchical, displayHierarchicalByExecutionPathSorted, and startBench.


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