Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cTaskProfiler Class Reference

#include <cTaskProfiler.h>

Public Member Functions

 cTaskProfiler (TASK_PROFILER_t iQtyTasks)
 
virtual ~cTaskProfiler ()
 
bool isProfilingActive () const
 
TIMESECD_t get_SampleWindowLen () const
 
void put_SampleWindowLen (TIMESECD_t iSampleWindowSec)
 
TASK_PROFILER_t get_TaskQty () const
 
TASK_PROFILER_t get_TaskCurrent () const
 
TASK_PROFILER_t SwitchTask (TASK_PROFILER_t idTask)
 
void IncTaskCount (TASK_PROFILER_t idTask, UINT nSamples, TIMEPERF_t Type=cTaskProfilerRec::k_NOTIME_BYTERATE)
 
void SetTaskCount (TASK_PROFILER_t idTask, UINT nSamples, TIMEPERF_t Type=cTaskProfilerRec::k_NOTIME_COUNT)
 
cStringA GetTaskStatusDesc (TASK_PROFILER_t idTask) const
 
float GetTaskPercent (TASK_PROFILER_t idTask) const
 
TIMESECF_t GetTaskTimeSec (TASK_PROFILER_t idTask) const
 
TIMEPERF_t get_TaskDiff () const
 
double get_TaskDiffSec () const
 
virtual void OnSampleWindowComplete ()
 
 UNITTEST_FRIEND (cTaskProfiler)
 

Public Attributes

UINT m_nSampleFrame
 total number of sample frames. More...
 

Protected Member Functions

void InitTestCurrentWindow ()
 
void ClearCurrentWindow ()
 
cTaskProfilerRecGetTaskCur (TASK_PROFILER_t idTask)
 

Protected Attributes

const TASK_PROFILER_t m_iTaskQty
 
TIMESECD_t m_iSampleWindowSec
 The sample window size (in seconds). 0=off. More...
 
cTimePerf m_TimeWindowSize
 same as m_iSampleWindowSec but in cTimePerf units. More...
 
cThreadLockCount m_LockProf
 make sure we can't conflict this. More...
 
cArrayTyped< cTaskProfilerRec, cTaskProfilerRec & > m_PrvWindow
 
cArrayTyped< cTaskProfilerRec, cTaskProfilerRec & > m_CurWindow
 
cTimePerf m_TimeTotal
 Total time collected for this sample window. (so far) More...
 
cTaskProfilerThread m_Cur
 

Detailed Description

Track an apps transition from Task to Task. Accumulate how much time the app spends in each Task/State.

Note
Assume Task 0 (PROFILE_IDLE) is just an idle task. (i.e. System Sleep() etc)

Constructor & Destructor Documentation

◆ cTaskProfiler()

GrayLib::cTaskProfiler::cTaskProfiler ( TASK_PROFILER_t  iQtyTasks)
  • iTaskQty = how many tasks am i tracking ?

◆ ~cTaskProfiler()

GrayLib::cTaskProfiler::~cTaskProfiler ( )
virtual

Member Function Documentation

◆ ClearCurrentWindow()

void GrayLib::cTaskProfiler::ClearCurrentWindow ( )
protected

◆ get_SampleWindowLen()

TIMESECD_t GrayLib::cTaskProfiler::get_SampleWindowLen ( ) const
inline

◆ get_TaskCurrent()

TASK_PROFILER_t GrayLib::cTaskProfiler::get_TaskCurrent ( ) const
inline

What is the current task we are profiling?

◆ get_TaskDiff()

TIMEPERF_t GrayLib::cTaskProfiler::get_TaskDiff ( ) const
inline

How much time has passed for current task?

◆ get_TaskDiffSec()

double GrayLib::cTaskProfiler::get_TaskDiffSec ( ) const
inline

How much time has passed for current task? TIMESECF_t

◆ get_TaskQty()

TASK_PROFILER_t GrayLib::cTaskProfiler::get_TaskQty ( ) const
inline

◆ GetTaskCur()

cTaskProfilerRec& GrayLib::cTaskProfiler::GetTaskCur ( TASK_PROFILER_t  idTask)
inlineprotected

◆ GetTaskPercent()

float GrayLib::cTaskProfiler::GetTaskPercent ( TASK_PROFILER_t  idTask) const
inline

What percent of the CPU is this task using? 1=100%

◆ GetTaskStatusDesc()

cStringA GrayLib::cTaskProfiler::GetTaskStatusDesc ( TASK_PROFILER_t  idTask) const

Get Description of a certain task.

◆ GetTaskTimeSec()

TIMESECF_t GrayLib::cTaskProfiler::GetTaskTimeSec ( TASK_PROFILER_t  idTask) const
inline

What amount of time is this using ? TIMESECF_t seconds.

◆ IncTaskCount()

void GrayLib::cTaskProfiler::IncTaskCount ( TASK_PROFILER_t  idTask,
UINT  nSamples,
TIMEPERF_t  Type = cTaskProfilerRec::k_NOTIME_BYTERATE 
)
inline

Not used as a task, just a statistical counter.

◆ InitTestCurrentWindow()

void GrayLib::cTaskProfiler::InitTestCurrentWindow ( )
protected

◆ isProfilingActive()

bool GrayLib::cTaskProfiler::isProfilingActive ( ) const
inline

◆ OnSampleWindowComplete()

void GrayLib::cTaskProfiler::OnSampleWindowComplete ( )
virtual

Move to a next/new sample window. If NT we can push these values out to the registry !? override this.

◆ put_SampleWindowLen()

void GrayLib::cTaskProfiler::put_SampleWindowLen ( TIMESECD_t  iSampleWindowSec)

Start the timers going. Set the sample window size.

◆ SetTaskCount()

void GrayLib::cTaskProfiler::SetTaskCount ( TASK_PROFILER_t  idTask,
UINT  nSamples,
TIMEPERF_t  Type = cTaskProfilerRec::k_NOTIME_COUNT 
)
inline

Not used as a task, just a statistical counter.

◆ SwitchTask()

TASK_PROFILER_t GrayLib::cTaskProfiler::SwitchTask ( TASK_PROFILER_t  idTask)

Stop the previous task and start a new one. Accumulate how much time is spent in each task.

Note
This MUST BE VERY FAST !
Returns
The id of the previous task.

◆ UNITTEST_FRIEND()

GrayLib::cTaskProfiler::UNITTEST_FRIEND ( cTaskProfiler  )

Member Data Documentation

◆ m_Cur

cTaskProfilerThread GrayLib::cTaskProfiler::m_Cur
protected

◆ m_CurWindow

cArrayTyped<cTaskProfilerRec, cTaskProfilerRec&> GrayLib::cTaskProfiler::m_CurWindow
protected

◆ m_iSampleWindowSec

TIMESECD_t GrayLib::cTaskProfiler::m_iSampleWindowSec
protected

The sample window size (in seconds). 0=off.

◆ m_iTaskQty

const TASK_PROFILER_t GrayLib::cTaskProfiler::m_iTaskQty
protected

◆ m_LockProf

cThreadLockCount GrayLib::cTaskProfiler::m_LockProf
mutableprotected

make sure we can't conflict this.

◆ m_nSampleFrame

UINT GrayLib::cTaskProfiler::m_nSampleFrame

total number of sample frames.

◆ m_PrvWindow

cArrayTyped<cTaskProfilerRec, cTaskProfilerRec&> GrayLib::cTaskProfiler::m_PrvWindow
protected

◆ m_TimeTotal

cTimePerf GrayLib::cTaskProfiler::m_TimeTotal
protected

Total time collected for this sample window. (so far)

◆ m_TimeWindowSize

cTimePerf GrayLib::cTaskProfiler::m_TimeWindowSize
protected

same as m_iSampleWindowSec but in cTimePerf units.


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