Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

vpr::ProfileNode Class Reference

A node in the Profile Hierarchy Tree. More...

#include <ProfileNode.h>

Collaboration diagram for vpr::ProfileNode:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::pair< std::deque<
float >::const_iterator,
std::deque< float >::const_iterator > 
NodeHistoryRange

Public Methods

 ProfileNode (const char *name, ProfileNode *parent)
 constructor for a profile node Takes a static string pointer for the name and a reference to a parent. More...

 ProfileNode (const char *name, ProfileNode *parent, const unsigned int queue_size)
 ~ProfileNode (void)
 destructor. More...

ProfileNode * getSubNode (const char *name)
 Returns a pointer to a subnode of this node given the name of the subnode If the name doesn't exist it creates the new node and adds it as a child to this node and returns this new node. More...

ProfileNode * getSubNode (const char *name, const unsigned int queue_size)
ProfileNode * getParent (void)
 return This nodes parent. More...

ProfileNode * getSibling (void)
ProfileNode * getChild (void)
void printTree (ProfileNode *node)
void reset (void)
void call (void)
bool Return (void)
const char * getName (void)
int getTotalCalls (void)
float getTotalTime (void)
const NodeHistoryRange getNodeHistoryRange ()
void clearHistory ()

Protected Attributes

const char * mName
int mTotalCalls
float mTotalTime
std::deque< float > mHistory
unsigned int mHistorySize
vpr::Interval mStartTime
int mRecursionCounter
ProfileNode * mParent
ProfileNode * mChild
ProfileNode * mSibling

Detailed Description

A node in the Profile Hierarchy Tree.

Definition at line 35 of file ProfileNode.h.


Member Typedef Documentation

typedef std::pair< std::deque<float>::const_iterator, std::deque<float>::const_iterator> vpr::ProfileNode::NodeHistoryRange
 

Definition at line 86 of file ProfileNode.h.

Referenced by getNodeHistoryRange, and printTree.


Constructor & Destructor Documentation

vpr::ProfileNode::ProfileNode const char *    name,
ProfileNode *    parent
 

constructor for a profile node Takes a static string pointer for the name and a reference to a parent.

Definition at line 9 of file ProfileNode.cpp.

References mHistory, mHistorySize, mStartTime, reset, and vpr::Interval::secf.

Referenced by getChild, getParent, getSibling, and getSubNode.

00009                                                                   :
00010    mName( name ),
00011    mTotalCalls( 0 ),
00012    mTotalTime( 0 ),
00013    mRecursionCounter( 0 ),
00014    mParent( parent ),
00015    mChild( NULL ),
00016    mSibling( NULL )
00017 {
00018    mHistorySize = 1;
00019    mHistory.resize(mHistorySize);
00020    mStartTime.secf(0);
00021    reset();
00022 }

vpr::ProfileNode::ProfileNode const char *    name,
ProfileNode *    parent,
const unsigned int    queue_size
 

Definition at line 24 of file ProfileNode.cpp.

References mHistory, mHistorySize, mStartTime, reset, and vpr::Interval::secf.

00024                                                                                                 :
00025    mName( name ),
00026    mTotalCalls( 0 ),
00027    mTotalTime( 0 ),
00028    mRecursionCounter( 0 ),
00029    mParent( parent ),
00030    mChild( NULL ),
00031    mSibling( NULL )
00032 {
00033    mHistorySize = queue_size;
00034    mHistory.resize(mHistorySize);
00035    mStartTime.secf(0);
00036    reset();
00037 }

vpr::ProfileNode::~ProfileNode void   
 

destructor.

Definition at line 39 of file ProfileNode.cpp.

References mChild, and mSibling.

00040 {
00041    delete mChild;
00042    delete mSibling;
00043 }


Member Function Documentation

ProfileNode * vpr::ProfileNode::getSubNode const char *    name
 

Returns a pointer to a subnode of this node given the name of the subnode If the name doesn't exist it creates the new node and adds it as a child to this node and returns this new node.

Definition at line 45 of file ProfileNode.cpp.

References mChild, and ProfileNode.

00046 {
00047    // Try to find this sub node
00048    ProfileNode* child = mChild;
00049    while ( child ) {
00050       if ( child->mName == name ) {
00051          return child;
00052       }
00053       child = child->mSibling;
00054    }
00055 
00056    // We didn't find it, so add it
00057    ProfileNode* node = new ProfileNode( name, this );
00058    node->mSibling = mChild;
00059    mChild = node;
00060    return node;
00061 }

ProfileNode * vpr::ProfileNode::getSubNode const char *    name,
const unsigned int    queue_size
 

Definition at line 63 of file ProfileNode.cpp.

References mChild, and ProfileNode.

00064 {
00065    // Try to find this sub node
00066    ProfileNode* child = mChild;
00067    while ( child ) {
00068       if ( child->mName == name ) {
00069          return child;
00070       }
00071       child = child->mSibling;
00072    }
00073 
00074    // We didn't find it, so add it
00075    ProfileNode* node = new ProfileNode( name, this, queue_size);
00076    node->mSibling = mChild;
00077    mChild = node;
00078    return node;
00079 }

ProfileNode* vpr::ProfileNode::getParent void    [inline]
 

return This nodes parent.

Definition at line 64 of file ProfileNode.h.

References mParent, and ProfileNode.

00064 { return mParent; }

ProfileNode* vpr::ProfileNode::getSibling void    [inline]
 

Returns:
A pointer to a sibling node.

Definition at line 69 of file ProfileNode.h.

References mSibling, and ProfileNode.

00069 { return mSibling; }

ProfileNode* vpr::ProfileNode::getChild void    [inline]
 

Returns:
A pointer to its child.

Definition at line 74 of file ProfileNode.h.

References mChild, and ProfileNode.

00074 { return mChild; }

void vpr::ProfileNode::printTree ProfileNode *    node
 

Definition at line 81 of file ProfileNode.cpp.

References clrGREEN, clrOutBOLD, clrRED, clrRESET, clrSetBOLD, clrYELLOW, NodeHistoryRange, vprDBG_ALL, vprDEBUG, and vprDEBUG_FLUSH.

00082 {
00083    if(node == NULL) return;
00084 
00085    ProfileNode::printTree(node->getSibling());
00086 
00087    vprDEBUG(vprDBG_ALL, 0) << clrSetBOLD(clrGREEN) << "[PROFILE STATS] " << clrRESET 
00088       << clrSetBOLD(clrRED) << node->getName() << clrRESET << clrSetBOLD(clrYELLOW)  
00089       << " total calls: " << clrRESET << node->getTotalCalls()
00090       << clrSetBOLD(clrYELLOW) << " total time: " << clrRESET << node->getTotalTime()
00091       << clrSetBOLD(clrYELLOW) << " ave: " << clrRESET 
00092       << node->getTotalTime() / node->getTotalCalls() << std::endl << vprDEBUG_FLUSH;
00093 
00094    std::stringstream s;
00095    NodeHistoryRange p = node->getNodeHistoryRange();
00096    for(; p.first != p.second; p.first++)
00097    {
00098       s << *(p.first) << " ";
00099    }
00100 
00101    vprDEBUG(vprDBG_ALL, 0)  << clrOutBOLD(clrYELLOW, " history: ")
00102       << s.str() << std::endl << vprDEBUG_FLUSH;
00103 
00104    ProfileNode::printTree(node->getChild());
00105 
00106 }

void vpr::ProfileNode::reset void   
 

Definition at line 109 of file ProfileNode.cpp.

References mChild, mSibling, mTotalCalls, and mTotalTime.

Referenced by ProfileNode.

00110 {
00111    mTotalCalls = 0;
00112    mTotalTime = 0.0f;
00113 
00114    if ( mChild ) {
00115       mChild->reset();
00116    }
00117    if ( mSibling ) {
00118       mSibling->reset();
00119    }
00120 }

void vpr::ProfileNode::call void   
 

Definition at line 122 of file ProfileNode.cpp.

References mRecursionCounter, mStartTime, mTotalCalls, and vpr::profileGetTicks.

00123 {
00124    mTotalCalls++;
00125    if (mRecursionCounter++ == 0) {
00126       profileGetTicks(&mStartTime);
00127    }
00128 }

bool vpr::ProfileNode::Return void   
 

Definition at line 130 of file ProfileNode.cpp.

References mHistory, mHistorySize, mRecursionCounter, mStartTime, mTotalCalls, mTotalTime, vpr::profileGetTickRate, vpr::profileGetTicks, and vpr::Interval::secf.

00131 {
00132    if ( --mRecursionCounter == 0 && mTotalCalls != 0 ) { 
00133       vpr::Interval time;
00134       profileGetTicks(&time);
00135       time-=mStartTime;
00136       mHistory.push_front((float)(time.secf() / profileGetTickRate().secf()));
00137       mHistory.resize(mHistorySize);
00138       mTotalTime += mHistory.front();
00139    }
00140    return ( mRecursionCounter == 0 );
00141 }

const char* vpr::ProfileNode::getName void    [inline]
 

Definition at line 82 of file ProfileNode.h.

References mName.

00082 { return mName; }

int vpr::ProfileNode::getTotalCalls void    [inline]
 

Definition at line 83 of file ProfileNode.h.

References mTotalCalls.

00083 { return mTotalCalls; }

float vpr::ProfileNode::getTotalTime void    [inline]
 

Definition at line 84 of file ProfileNode.h.

References mTotalTime.

00084 { return mTotalTime; }

const NodeHistoryRange vpr::ProfileNode::getNodeHistoryRange   [inline]
 

Definition at line 88 of file ProfileNode.h.

References mHistory, and NodeHistoryRange.

00088 { return std::make_pair(mHistory.begin(), mHistory.end()); }

void vpr::ProfileNode::clearHistory   [inline]
 

Definition at line 90 of file ProfileNode.h.

References mHistory.

00090 {mHistory.clear(); }


Member Data Documentation

const char* vpr::ProfileNode::mName [protected]
 

Definition at line 95 of file ProfileNode.h.

Referenced by getName.

int vpr::ProfileNode::mTotalCalls [protected]
 

Definition at line 96 of file ProfileNode.h.

Referenced by call, getTotalCalls, reset, and Return.

float vpr::ProfileNode::mTotalTime [protected]
 

Definition at line 97 of file ProfileNode.h.

Referenced by getTotalTime, reset, and Return.

std::deque<float> vpr::ProfileNode::mHistory [protected]
 

Definition at line 99 of file ProfileNode.h.

Referenced by clearHistory, getNodeHistoryRange, ProfileNode, and Return.

unsigned int vpr::ProfileNode::mHistorySize [protected]
 

Definition at line 100 of file ProfileNode.h.

Referenced by ProfileNode, and Return.

vpr::Interval vpr::ProfileNode::mStartTime [protected]
 

Definition at line 102 of file ProfileNode.h.

Referenced by call, ProfileNode, and Return.

int vpr::ProfileNode::mRecursionCounter [protected]
 

Definition at line 103 of file ProfileNode.h.

Referenced by call, and Return.

ProfileNode* vpr::ProfileNode::mParent [protected]
 

Definition at line 105 of file ProfileNode.h.

Referenced by getParent.

ProfileNode* vpr::ProfileNode::mChild [protected]
 

Definition at line 106 of file ProfileNode.h.

Referenced by getChild, getSubNode, reset, and ~ProfileNode.

ProfileNode* vpr::ProfileNode::mSibling [protected]
 

Definition at line 107 of file ProfileNode.h.

Referenced by getSibling, reset, and ~ProfileNode.


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:47:10 2004 for VR Juggler Portable Runtime by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002