Clean up warning level (warning level 4) from profiling class

This commit is contained in:
zilmar 2012-10-05 19:18:02 +10:00
parent 856e9838dc
commit b809b57faa
3 changed files with 58 additions and 53 deletions

View File

@ -8,8 +8,6 @@ CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) :
m_MMU_VM(this,SavesReadOnly),
m_TLB(this),
m_FPS(_Notify),
m_CPU_Usage(_Notify),
m_Profile(_Notify),
m_Limitor(_Notify),
m_Plugins(Plugins),
m_Cheats(NULL),
@ -825,7 +823,6 @@ void CN64System::ExecuteSyncCPU ()
}
void CN64System::CpuStopped ( void ) {
void * lCPU_Handle = m_CPU_Handle;
_Settings->SaveBool(GameRunning_CPU_Running,(DWORD)false);
_Notify->WindowMode();
if (!m_InReset)
@ -1303,7 +1300,7 @@ bool CN64System::LoadState(void)
}
bool CN64System::LoadState(LPCSTR FileName) {
DWORD dwRead, Value,SaveRDRAMSize, NextVITimer;
DWORD dwRead, Value,SaveRDRAMSize, NextVITimer = 0;
bool LoadedZipFile = false;
WriteTraceF((TraceType)(TraceDebug | TraceRecompiler),"CN64System::LoadState %s",FileName);
@ -1504,7 +1501,7 @@ void CN64System::RunRSP ( void ) {
if ( ( m_Reg.SP_STATUS_REG & SP_STATUS_HALT ) == 0) {
if ( ( m_Reg.SP_STATUS_REG & SP_STATUS_BROKE ) == 0 ) {
DWORD Task; _MMU->LW_VAddr(0xA4000FC0,Task);
DWORD CPU_UsageAddr = Timer_None, ProfileAddr = Timer_None;
SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfileAddr = Timer_None*/;
if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0)
{
@ -1594,7 +1591,7 @@ void CN64System::SyncToAudio ( void ) {
return;
}
DWORD CPU_UsageAddr = Timer_None;
SPECIAL_TIMERS CPU_UsageAddr = Timer_None;
if (bShowCPUPer())
{
CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_Idel);
@ -1615,8 +1612,8 @@ void CN64System::SyncToAudio ( void ) {
}
void CN64System::RefreshScreen ( void ) {
DWORD CPU_UsageAddr = Timer_None, ProfilingAddr = Timer_None;
DWORD OLD_VI_V_SYNC_REG = 0, VI_INTR_TIME = 500000;
SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfilingAddr = Timer_None*/;
DWORD VI_INTR_TIME = 500000;
if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); }
//if (bProfiling) { ProfilingAddr = m_Profile.StartTimer(Timer_RefreshScreen); }

View File

@ -2,15 +2,18 @@
enum { MAX_FRAMES = 13 };
CProfiling::CProfiling (CNotification * Notify) {
_Notify = Notify;
CurrentTimerAddr = Timer_None;
CurrentDisplayCount = MAX_FRAMES;
CProfiling::CProfiling () :
m_CurrentTimerAddr(Timer_None),
m_CurrentDisplayCount(MAX_FRAMES),
m_StartTimeHi(0),
m_StartTimeLo(0)
{
}
DWORD CProfiling::StartTimer(DWORD Address) {
DWORD OldTimerAddr = StopTimer();
CurrentTimerAddr = Address;
SPECIAL_TIMERS CProfiling::StartTimer(SPECIAL_TIMERS Address)
{
SPECIAL_TIMERS OldTimerAddr = StopTimer();
m_CurrentTimerAddr = Address;
DWORD HiValue, LoValue;
_asm {
@ -20,15 +23,15 @@ DWORD CProfiling::StartTimer(DWORD Address) {
mov LoValue, eax
popad
}
StartTimeHi = HiValue;
StartTimeLo = LoValue;
m_StartTimeHi = HiValue;
m_StartTimeLo = LoValue;
return OldTimerAddr;
}
DWORD CProfiling::StopTimer(void) {
SPECIAL_TIMERS CProfiling::StopTimer(void) {
DWORD HiValue, LoValue;
if (CurrentTimerAddr == Timer_None) { return CurrentTimerAddr; }
if (m_CurrentTimerAddr == Timer_None) { return m_CurrentTimerAddr; }
_asm {
pushad
@ -39,18 +42,18 @@ DWORD CProfiling::StopTimer(void) {
}
__int64 StopTime = ((unsigned __int64)HiValue << 32) + (unsigned __int64)LoValue;
__int64 StartTime = ((unsigned __int64)StartTimeHi << 32) + (unsigned __int64)StartTimeLo;
__int64 StartTime = ((unsigned __int64)m_StartTimeHi << 32) + (unsigned __int64)m_StartTimeLo;
__int64 TimeTaken = StopTime - StartTime;
PROFILE_ENRTY Entry = Entries.find(CurrentTimerAddr);
if (Entry != Entries.end()) {
PROFILE_ENRTY Entry = m_Entries.find(m_CurrentTimerAddr);
if (Entry != m_Entries.end()) {
Entry->second += TimeTaken;
} else {
Entries.insert(PROFILE_ENRTIES::value_type(CurrentTimerAddr,TimeTaken));
m_Entries.insert(PROFILE_ENRTIES::value_type(m_CurrentTimerAddr,TimeTaken));
}
DWORD OldTimerAddr = CurrentTimerAddr;
CurrentTimerAddr = Timer_None;
SPECIAL_TIMERS OldTimerAddr = m_CurrentTimerAddr;
m_CurrentTimerAddr = Timer_None;
return OldTimerAddr;
}
@ -58,26 +61,26 @@ void CProfiling::ShowCPU_Usage (void) {
__int64 TotalTime, CPU = 0, Alist = 0, Dlist = 0, Idle = 0;
PROFILE_ENRTY Entry;
if (CurrentDisplayCount > 0) { CurrentDisplayCount -= 1; return; }
CurrentDisplayCount = MAX_FRAMES;
if (m_CurrentDisplayCount > 0) { m_CurrentDisplayCount -= 1; return; }
m_CurrentDisplayCount = MAX_FRAMES;
Entry = Entries.find(Timer_R4300);
if (Entry != Entries.end()) { CPU = Entry->second; }
Entry = m_Entries.find(Timer_R4300);
if (Entry != m_Entries.end()) { CPU = Entry->second; }
Entry = Entries.find(Timer_RefreshScreen);
if (Entry != Entries.end()) { CPU += Entry->second; }
Entry = m_Entries.find(Timer_RefreshScreen);
if (Entry != m_Entries.end()) { CPU += Entry->second; }
Entry = Entries.find(Timer_RSP_Dlist);
if (Entry != Entries.end()) { Dlist = Entry->second; }
Entry = m_Entries.find(Timer_RSP_Dlist);
if (Entry != m_Entries.end()) { Dlist = Entry->second; }
Entry = Entries.find(Timer_UpdateScreen);
if (Entry != Entries.end()) { Dlist += Entry->second; }
Entry = m_Entries.find(Timer_UpdateScreen);
if (Entry != m_Entries.end()) { Dlist += Entry->second; }
Entry = Entries.find(Timer_RSP_Alist);
if (Entry != Entries.end()) { Alist = Entry->second; }
Entry = m_Entries.find(Timer_RSP_Alist);
if (Entry != m_Entries.end()) { Alist = Entry->second; }
Entry = Entries.find(Timer_Idel);
if (Entry != Entries.end()) { Idle = Entry->second; }
Entry = m_Entries.find(Timer_Idel);
if (Entry != m_Entries.end()) { Idle = Entry->second; }
TotalTime = CPU + Alist + Dlist + Idle;
@ -92,7 +95,7 @@ void CProfiling::ShowCPU_Usage (void) {
}
void CProfiling::ResetCounters (void) {
Entries.clear();
m_Entries.clear();
}
typedef struct { SPECIAL_TIMERS Timer; char * Name; } TIMER_NAME;
@ -106,13 +109,13 @@ void CProfiling::GenerateLog(void) {
//Get the total time
__int64 TotalTime = 0;
for (PROFILE_ENRTY itemTime = Entries.begin(); itemTime != Entries.end(); itemTime++ ) {
for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++ ) {
TotalTime += itemTime->second;
}
//Create a sortable list of items
std::vector<PROFILE_VALUE *> ItemList;
for (PROFILE_ENRTY Entry = Entries.begin(); Entry != Entries.end(); Entry++ ) {
for (PROFILE_ENRTY Entry = m_Entries.begin(); Entry != m_Entries.end(); Entry++ ) {
ItemList.push_back(&(*Entry));
}

View File

@ -1,21 +1,16 @@
typedef std::map<DWORD, __int64 > PROFILE_ENRTIES;
typedef std::map<SPECIAL_TIMERS, __int64 > PROFILE_ENRTIES;
typedef PROFILE_ENRTIES::iterator PROFILE_ENRTY;
typedef PROFILE_ENRTIES::value_type PROFILE_VALUE;
class CProfiling {
CNotification * _Notify;
DWORD CurrentTimerAddr, CurrentDisplayCount;
DWORD StartTimeHi, StartTimeLo; //The Current Timer start time
PROFILE_ENRTIES Entries;
class CProfiling
{
public:
CProfiling (CNotification * Notify);
CProfiling (void);
//recording timing against current timer, returns the address of the timer stoped
DWORD StartTimer ( DWORD Address );
DWORD StopTimer ( void );
SPECIAL_TIMERS StartTimer ( SPECIAL_TIMERS Address );
SPECIAL_TIMERS StopTimer ( void );
//Display the CPU Usage
void ShowCPU_Usage ( void );
@ -25,4 +20,14 @@ public:
//Generate a log file with the current results, this will also reset the counters
void GenerateLog ( void );
private:
CProfiling(const CProfiling&); // Disable copy constructor
CProfiling& operator=(const CProfiling&); // Disable assignment
SPECIAL_TIMERS m_CurrentTimerAddr;
DWORD m_CurrentDisplayCount;
DWORD m_StartTimeHi, m_StartTimeLo; //The Current Timer start time
PROFILE_ENRTIES m_Entries;
};