Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

AProfiler.cpp File Reference


Detailed Description

This is the header file declaring the public interface of the AEngine (extended upon the Aierra engine).

This engine provides the following functionality

Definition in file AProfiler.cpp.

#include "AEngine.h"
#include "AState.h"
#include "AConstants.h"
#include "ADevice.h"
#include "ASharedFunc.h"

Include dependency graph for AProfiler.cpp:

Include dependency graph

Go to the source code of this file.

Functions

__int64 getOSTime ()
void profiler_begin (string s)
void profiler_end (string s)
void profiler_reset ()
void profiler_render ()


Function Documentation

__int64 getOSTime   [inline]
 

Definition at line 38 of file AProfiler.cpp.

References time.

Referenced by profiler_begin(), profiler_end(), profiler_render(), and profiler_reset().

00039 {
00040         __int64 time;
00041         int *dest_low  = (int*) (&time);
00042         int *dest_high = dest_low + 1;  
00043 
00044         __asm
00045         {
00046                 rdtsc;
00047                 mov             ebx,    dest_low;
00048                 mov             ecx,    dest_high;
00049                 mov             [ebx],  eax;
00050                 mov             [ecx],  edx;
00051         }
00052 
00053         return time;
00054 }

void profiler_begin string    s
 

Definition at line 56 of file AProfiler.cpp.

References getOSTime().

Referenced by AProfilerBlock::AProfilerBlock(), and doGameLoop().

00057 {
00058         map<string,__int64>::iterator iter;
00059         iter = AS.profiler_startTime.find(s);
00060         if( iter==AS.profiler_startTime.end() )         // if this is the first time we come across this name
00061         {
00062                 AS.profiler_startTime[s] = getOSTime();
00063                 AS.profiler_totalTime[s] = 0;           
00064                 AS.profiler_names.push_back(s);
00065         }
00066         else
00067         {
00068                 AS.profiler_startTime[s] = getOSTime();
00069         }
00070 }

void profiler_end string    s
 

Definition at line 72 of file AProfiler.cpp.

References getOSTime().

Referenced by doGameLoop(), and AProfilerBlock::~AProfilerBlock().

00073 {
00074         map<string,__int64>::iterator iter;
00075         iter = AS.profiler_totalTime.find(s);
00076         if( iter==AS.profiler_totalTime.end() )
00077         {
00078                 throw Error("Profiler_end("+s+")  not preceded by Profiler_begin");
00079         }
00080         else
00081         {
00082                 iter->second += getOSTime() - AS.profiler_startTime.find(s)->second;            
00083         }
00084 }

void profiler_render  
 

Definition at line 94 of file AProfiler.cpp.

References getOSTime(), sys_console(), and UINT.

Referenced by doGameLoop().

00095 {
00096         sys_console() << "-------BEGIN-PROFILER-SUMMARY-------" << endl;
00097         __int64 t = getOSTime();
00098         __int64 deltaT = t - AS.profiler_RDTSClastReset;
00099         for( UINT i=0; i<AS.profiler_names.size(); i++ )
00100         {
00101                 string s = AS.profiler_names[i];
00102                 FLOAT percent = AS.profiler_totalTime.find(s)->second * 100.0f / deltaT;
00103                 while( s.length()<24 ) s += " ";                
00104                 sys_console() << s << percent << endl;
00105         }
00106 }

void profiler_reset  
 

Definition at line 86 of file AProfiler.cpp.

References getOSTime(), sys_getMilliSec(), and UINT.

Referenced by doGameLoop().

00087 {
00088         for( UINT i=0; i<AS.profiler_names.size(); i++ )
00089                 AS.profiler_totalTime.find( AS.profiler_names[i] )->second = 0;
00090         AS.profiler_RDTSClastReset = getOSTime();
00091         AS.profiler_MSlastReset    = sys_getMilliSec();
00092 }


Generated on Wed Apr 23 05:50:31 2003 for Modern Warfare by doxygen1.3-rc2