Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
TaskProfile Class Reference

a simple class to keep track of one task that may be called multiple times. More...

#include <Profiler.h>

Collaboration diagram for TaskProfile:
[legend]

Public Member Functions

 TaskProfile ()
 Task Profile. More...
 
virtual ~TaskProfile ()
 
void Begin (const char *fileName, int lineNum, const char *taskDescription)
 start the task timer. More...
 
void End (const char *fileName, int lineNum, const char *taskDescription)
 end the task timer. More...
 
double ComputeAverageRunTime ()
 

Public Attributes

ArrayOf< char > mFileName
 
int mLine
 
ArrayOf< char > mDescription
 
int mNumHits
 
clock_t mCumTime
 
clock_t mLastTime
 

Detailed Description

a simple class to keep track of one task that may be called multiple times.

Definition at line 69 of file Profiler.h.

Constructor & Destructor Documentation

◆ TaskProfile()

TaskProfile::TaskProfile ( )

Task Profile.

Definition at line 116 of file Profiler.cpp.

117{
118 mCumTime=0;
119 mNumHits=0;
120}
int mNumHits
Definition: Profiler.h:85
clock_t mCumTime
Definition: Profiler.h:86

References mCumTime, and mNumHits.

◆ ~TaskProfile()

TaskProfile::~TaskProfile ( )
virtual

Definition at line 122 of file Profiler.cpp.

123{
124}

Member Function Documentation

◆ Begin()

void TaskProfile::Begin ( const char *  fileName,
int  lineNum,
const char *  taskDescription 
)

start the task timer.

Definition at line 127 of file Profiler.cpp.

128{
129 if(!mFileName)
130 {
131 mFileName.reinit( strlen(fileName) + 1 );
132 strcpy(mFileName.get(), fileName);
133 mDescription.reinit( strlen(taskDescription) + 1 );
134 strcpy(mDescription.get(), taskDescription);
135 mLine = lineNum;
136 }
137
138 mLastTime = clock();
139
140}
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:56
clock_t mLastTime
Definition: Profiler.h:87
ArrayOf< char > mDescription
Definition: Profiler.h:84
ArrayOf< char > mFileName
Definition: Profiler.h:82
int mLine
Definition: Profiler.h:83

References mDescription, mFileName, mLastTime, mLine, and ArrayOf< X >::reinit().

Referenced by Profiler::Begin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeAverageRunTime()

double TaskProfile::ComputeAverageRunTime ( )

Definition at line 149 of file Profiler.cpp.

150{
151 if(mNumHits)
152 return (double) ((double)mCumTime/CLOCKS_PER_SEC)/mNumHits;
153 else
154 return 0.0;
155}

References mCumTime, and mNumHits.

◆ End()

void TaskProfile::End ( const char *  fileName,
int  lineNum,
const char *  taskDescription 
)

end the task timer.

Definition at line 143 of file Profiler.cpp.

144{
145 mCumTime += clock() - mLastTime;
146 mNumHits++;
147}

References mCumTime, mLastTime, and mNumHits.

Referenced by Profiler::End().

Here is the caller graph for this function:

Member Data Documentation

◆ mCumTime

clock_t TaskProfile::mCumTime

Definition at line 86 of file Profiler.h.

Referenced by ComputeAverageRunTime(), End(), and TaskProfile().

◆ mDescription

ArrayOf<char> TaskProfile::mDescription

Definition at line 84 of file Profiler.h.

Referenced by Begin().

◆ mFileName

ArrayOf<char> TaskProfile::mFileName

Definition at line 82 of file Profiler.h.

Referenced by Begin().

◆ mLastTime

clock_t TaskProfile::mLastTime

Definition at line 87 of file Profiler.h.

Referenced by Begin(), and End().

◆ mLine

int TaskProfile::mLine

Definition at line 83 of file Profiler.h.

Referenced by Begin().

◆ mNumHits

int TaskProfile::mNumHits

Definition at line 85 of file Profiler.h.

Referenced by ComputeAverageRunTime(), End(), and TaskProfile().


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