CamProfiler Class Reference

To report on time taken in various CamProfile sections Notes: In the OIL See Also: CamProfile. More...

#include <camprofile.h>

Inheritance diagram for CamProfiler:

CCObject SimpleCCObject List of all members.

Public Member Functions

 CamProfiler ()
 Default constructor.
void Reset ()
 Resets counters to current.
double Read (double Results[CAMPROFILE_NONE])
 Reads counters.

Private Attributes

UINT64 OilTimeArray [CAMPROFILE_NONE]
UINT64 FirstOilTime

Detailed Description

To report on time taken in various CamProfile sections Notes: In the OIL See Also: CamProfile.

Author:
Alex_Bligh <alex@alex.org.uk>
Date:
24/11/2005
This class allows the user to maintain a set of timers that will be updated depending on the time spent in Camelot in various CamProfile sections (see header for CamProfile).

To use: CamProfiler myProfile;

... do some stuff ...

double results[CAMPROFILE_NONE] myProfile->Read(results); // Read results in microseconds

All this class actually does is store the values of CamProfile::OilTimeArray array when it's created, Read() then performs a subtraction to give the elapsed time in each element.

Definition at line 224 of file camprofile.h.


Constructor & Destructor Documentation

CamProfiler::CamProfiler  ) 
 

Default constructor.

Author:
Alex_Bligh <alex@alex.org.uk>
Date:
24/11/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 685 of file camprofile.cpp.

00686 {
00687     Reset();
00688 }


Member Function Documentation

double CamProfiler::Read double  Results[CAMPROFILE_NONE]  ) 
 

Reads counters.

Author:
Alex_Bligh <alex@alex.org.uk>
Date:
24/11/2005
Parameters:
- [INPUTS]
Results[CAMPROFILE_NONE] - array of doubles filled with number of seconds elapsed [OUTPUTS]
Returns:
total elapsed time

Errors: -

See also:
-
Results may be NULL, in which case only the total elapsed time will be returned.

The results in the array should add up to the total returned, but may not if profiling has been turned off in the mean time.

Definition at line 734 of file camprofile.cpp.

00735 {
00736     CamProfileMode Mode;
00737     CamProfile::UpdateOilTimes();
00738 
00739 #if WIN32
00740     // This windows code completely untested by Alex
00741     const double factor = 1.0/10000000.0; // Windows uses 100 nanosecond timeslices apparently
00742 #else
00743     const double factor = 1.0/1000000.0; // UNIX counts in microseconds
00744 #endif
00745 
00746     INT64 check = 0;
00747 
00748     for (Mode = (CamProfileMode)0 ; Mode < CAMPROFILE_NONE ; Mode=(CamProfileMode)((INT32)Mode+1))
00749     {
00750         // Cast via INT64 to cope with wrap event (ha ha ha).
00751         if (Results)
00752             Results[Mode] = factor * (double)((INT64)(CamProfile::OilTimeArray[Mode] - OilTimeArray[Mode]));
00753         TRACE(_T("CAMPROFILER type %d=%lld\n"),(INT32)Mode,CamProfile::OilTimeArray[Mode] - OilTimeArray[Mode]);
00754         check+=CamProfile::OilTimeArray[Mode] - OilTimeArray[Mode];
00755     }
00756 
00757     INT64 total = (INT64)(CamProfile::LastOilTime - FirstOilTime);
00758     TRACE(_T("CAMPROFILER check=%lld, total=%lld\n"),check,total);
00759 
00760     return factor * (double)(total);
00761 }

void CamProfiler::Reset void   ) 
 

Resets counters to current.

Author:
Alex_Bligh <alex@alex.org.uk>
Date:
24/11/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 706 of file camprofile.cpp.


Member Data Documentation

UINT64 CamProfiler::FirstOilTime [private]
 

Definition at line 236 of file camprofile.h.

UINT64 CamProfiler::OilTimeArray[CAMPROFILE_NONE] [private]
 

Definition at line 235 of file camprofile.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:51:50 2007 for Camelot by  doxygen 1.4.4