NLMISC::CHTimer::CStats Struct Reference

Inheritance diagram for NLMISC::CHTimer::CStats:

NLMISC::CHTimer::CNodeStat NLMISC::CHTimer::CTimerStat

Detailed Description

Some statistics They can be build from a set of nodes

Definition at line 335 of file hierarchical_timer.h.

Public Member Functions

void buildFromNode (CNode *node, double msPerTick)
void buildFromNodes (CNode **firstNode, uint numNodes, double msPerTick)
void display (CLog *log, bool displayEx=false, bool wantStandardDeviation=false)
void getStats (std::string &dest, bool statEx, double rootTotalTime, bool wantStandardDeviation=false)

Data Fields

double MaxTime
double MeanTime
double MinTime
uint64 NumVisits
double TimeStandardDeviation
double TotalTime
double TotalTimeWithoutSons


Member Function Documentation

void NLMISC::CHTimer::CStats::buildFromNode CNode node,
double  msPerTick
 

Definition at line 806 of file hierarchical_timer.cpp.

References buildFromNodes().

Referenced by NLMISC::CHTimer::display(), NLMISC::CHTimer::displayByExecutionPath(), NLMISC::CHTimer::displayHierarchical(), NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(), and NLMISC::CHTimer::displaySummary().

00807 {
00808         buildFromNodes(&node, 1, msPerTick);
00809 }

void NLMISC::CHTimer::CStats::buildFromNodes CNode **  firstNode,
uint  numNodes,
double  msPerTick
 

Definition at line 812 of file hierarchical_timer.cpp.

References NLMISC::CHTimer::CNode::LastSonsTotalTime, MeanTime, NLMISC::CHTimer::CNode::Measures, min, NLMISC::CHTimer::CNode::NumVisits, NLMISC::sqr(), TimeStandardDeviation, NLMISC::CHTimer::CNode::TotalTime, TotalTimeWithoutSons, uint, and uint64.

Referenced by buildFromNode(), and NLMISC::CHTimer::displayHierarchical().

00813 {
00814         TotalTime = 0;  
00815         TotalTimeWithoutSons = 0;       
00816         NumVisits = 0;
00817         
00818         uint64 minTime = (uint64) -1;
00819         uint64 maxTime = 0;
00820         
00821         uint k, l;
00822         for(k = 0; k < numNodes; ++k)
00823         {               
00824                 TotalTime += nodes[k]->TotalTime * msPerTick;
00825                 TotalTimeWithoutSons += (nodes[k]->TotalTime -  nodes[k]->LastSonsTotalTime) * msPerTick;
00826                 NumVisits += nodes[k]->NumVisits;
00827                 minTime = std::min(minTime, nodes[k]->MinTime);
00828                 maxTime = std::max(maxTime, nodes[k]->MaxTime);                         
00829         }
00830         if (minTime == (uint64) -1) 
00831         {
00832                 minTime = 0;
00833         }
00834         MinTime  = minTime * msPerTick;
00835         MaxTime  = maxTime * msPerTick;
00836         if (NumVisits > 0)
00837                 MeanTime = TotalTime / NumVisits;
00838         else
00839                 MeanTime = 0.0;
00840 
00841         // compute standard deviation
00842         double varianceSum = 0;
00843         uint   numMeasures = 0;
00844         for(k = 0; k < numNodes; ++k)
00845         {
00846                 numMeasures += nodes[k]->Measures.size();
00847                 for(l = 0; l < nodes[k]->Measures.size(); ++l)
00848                 {
00849                         varianceSum += NLMISC::sqr(nodes[k]->Measures[l] - MeanTime);
00850                 }               
00851         }
00852         TimeStandardDeviation = numMeasures == 0 ? 0
00853                                                                                          : ::sqrt(varianceSum / (numMeasures +1));
00854 }

void NLMISC::CHTimer::CStats::display CLog log,
bool  displayEx = false,
bool  wantStandardDeviation = false
 

Definition at line 857 of file hierarchical_timer.cpp.

References NLMISC::CLog::displayRawNL(), MeanTime, TimeStandardDeviation, and TotalTimeWithoutSons.

00858 {
00859         log->displayRawNL("HTIMER: Total time                = %.3f ms", (float) TotalTime);
00860         log->displayRawNL("HTIMER: Total time without sons   = %.3f ms", (float) TotalTimeWithoutSons);
00861         log->displayRawNL(("HTIMER: Num visits                = " + NLMISC::toString(NumVisits)).c_str());      
00862         if (displayEx)
00863         {
00864                         log->displayRawNL("HTIMER: Min time                  = %.3f ms", (float) MinTime);
00865                         log->displayRawNL("HTIMER: Max time                  = %.3f ms", (float) MaxTime);
00866                         log->displayRawNL("HTIMER: Mean time                 = %.3f ms", (float) MeanTime);
00867                         if (wantStandardDeviation)
00868                         {
00869                         log->displayRawNL("HTIMER: Standard deviation        = %.3f ms", (float) TimeStandardDeviation);
00870                         }
00871                         //log->displayRawNL("Time standard deviation    = %.3f ms", (float) TimeStandardDeviation);
00872         }
00873 }

void NLMISC::CHTimer::CStats::getStats std::string &  dest,
bool  statEx,
double  rootTotalTime,
bool  wantStandardDeviation = false
 

Get a string for stats (all stats on the same line)

Parameters:
statEx display extended stats

Definition at line 877 of file hierarchical_timer.cpp.

References MeanTime, NLMISC::smprintf(), TimeStandardDeviation, NLMISC::toString(), and TotalTimeWithoutSons.

Referenced by NLMISC::CHTimer::displayHierarchical(), NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(), and NLMISC::CHTimer::displaySummary().

00878 {
00879         char buf[1024];
00880         if (!wantStandardDeviation)
00881         {       
00882                 if (!statEx)
00883                 {       
00884                         NLMISC::smprintf(buf, 1024, " | %10.3f | %10.3f | %12s ", (float) TotalTime, (float) TotalTimeWithoutSons, toString(NumVisits).c_str());
00885                 }
00886                 else
00887                 {
00888                         NLMISC::smprintf(buf, 1024, " | %10.3f | %10.3f | %12s | %5.1f/%5.1f | %9.3f | %9.3f | %9.3f",
00889                                           (float) TotalTime, (float) TotalTimeWithoutSons, toString(NumVisits).c_str(), 
00890                                           float(100*TotalTimeWithoutSons/rootTotalTime), float(100*TotalTime/rootTotalTime), 
00891                                           (float) MinTime, (float) MaxTime, (float) MeanTime
00892                                          );
00893                 }
00894         }
00895         else
00896         {
00897                 if (!statEx)
00898                 {       
00899                         NLMISC::smprintf(buf, 1024, " | %10.3f | %10.3f | %12s | std deviation %9.3f", (float) TotalTime, (float) TotalTimeWithoutSons, toString(NumVisits).c_str(), (float) TimeStandardDeviation);
00900                 }
00901                 else
00902                 {
00903                         NLMISC::smprintf(buf, 1024, " | %10.3f | %10.3f | %12s | %5.1f/%5.1f | %9.3f | %9.3f | %9.3f | std deviation %9.3f",
00904                                                           (float) TotalTime, (float) TotalTimeWithoutSons, toString(NumVisits).c_str(), 
00905                                                           float(100*TotalTimeWithoutSons/rootTotalTime), float(100*TotalTime/rootTotalTime), 
00906                                                           (float) MinTime, (float) MaxTime, (float) MeanTime,
00907                                                           (float) TimeStandardDeviation
00908                                                         );
00909                 }
00910         }
00911         dest = buf;
00912 }


Field Documentation

double NLMISC::CHTimer::CStats::MaxTime
 

Definition at line 343 of file hierarchical_timer.h.

Referenced by NLMISC::CHTimer::CStatSorter::operator()().

double NLMISC::CHTimer::CStats::MeanTime
 

Definition at line 340 of file hierarchical_timer.h.

Referenced by buildFromNodes(), display(), getStats(), and NLMISC::CHTimer::CStatSorter::operator()().

double NLMISC::CHTimer::CStats::MinTime
 

Definition at line 342 of file hierarchical_timer.h.

Referenced by NLMISC::CHTimer::CStatSorter::operator()().

uint64 NLMISC::CHTimer::CStats::NumVisits
 

Definition at line 341 of file hierarchical_timer.h.

Referenced by NLMISC::CHTimer::CStatSorter::operator()().

double NLMISC::CHTimer::CStats::TimeStandardDeviation
 

Definition at line 337 of file hierarchical_timer.h.

Referenced by buildFromNodes(), display(), and getStats().

double NLMISC::CHTimer::CStats::TotalTime
 

Definition at line 338 of file hierarchical_timer.h.

Referenced by NLMISC::CHTimer::display(), NLMISC::CHTimer::displayByExecutionPath(), NLMISC::CHTimer::displayHierarchical(), NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(), NLMISC::CHTimer::displaySummary(), and NLMISC::CHTimer::CStatSorter::operator()().

double NLMISC::CHTimer::CStats::TotalTimeWithoutSons
 

Definition at line 339 of file hierarchical_timer.h.

Referenced by buildFromNodes(), display(), getStats(), and NLMISC::CHTimer::CStatSorter::operator()().


The documentation for this struct was generated from the following files:
Generated on Tue Mar 16 13:18:19 2004 for NeL by doxygen 1.3.6