Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
141
GameTools/CaldronBase/ProfileMgr.h
Normal file
141
GameTools/CaldronBase/ProfileMgr.h
Normal file
@@ -0,0 +1,141 @@
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CProfileMgr
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ProfileMgr.h
|
||||
* <20><><EFBFBD><EFBFBD> :
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2003.11.05
|
||||
* history :
|
||||
wizardbug ( 2003.11.05) :: Gem3<6D><33> Profile System<65><6D> Caldron<6F><6E> <20>°<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
/*
|
||||
** A node in the Profile Hierarchy Tree
|
||||
*/
|
||||
|
||||
#include "Caldron.h"
|
||||
#include "./LogMgr.h"
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
class CProfileObj {
|
||||
|
||||
public:
|
||||
CProfileObj( const char * strName, CProfileObj * pParent );
|
||||
~CProfileObj( void );
|
||||
|
||||
CProfileObj *Get_Sub_Node( const char * strName );
|
||||
|
||||
CProfileObj *Get_Parent( void ) { return m_pParent; }
|
||||
CProfileObj *Get_Sibling( void ) { return m_pSibling; }
|
||||
CProfileObj *Get_Child( void ) { return m_pChild; }
|
||||
|
||||
void Reset( void );
|
||||
void Call( void );
|
||||
bool Return( void );
|
||||
|
||||
const char *Get_Name( void ) { return m_strName; }
|
||||
int Get_Total_Calls( void ) { return m_iTotalCalls; }
|
||||
float Get_Total_Time( void ) { return m_fTotalTime; }
|
||||
|
||||
protected:
|
||||
|
||||
const char * m_strName;
|
||||
int m_iTotalCalls;
|
||||
float m_fTotalTime;
|
||||
__int64 m_iStartTime;
|
||||
int m_iRecursionCounter;
|
||||
|
||||
CProfileObj * m_pParent;
|
||||
CProfileObj * m_pChild;
|
||||
CProfileObj * m_pSibling;
|
||||
};
|
||||
|
||||
/*
|
||||
** An iterator to navigate through the tree
|
||||
*/
|
||||
class CProfileChecker
|
||||
{
|
||||
public:
|
||||
// Access all the children of the current parent
|
||||
void First(void);
|
||||
void Next(void);
|
||||
bool Is_Done(void);
|
||||
|
||||
void Enter_Child( int iIndex ); // Make the given child the new parent
|
||||
void Enter_Largest_Child( void ); // Make the largest child the new parent
|
||||
void Enter_Parent( void ); // Make the current parent's parent the new parent
|
||||
|
||||
// Access the current child
|
||||
const char * Get_Current_Name( void ) { return m_pCurrentChild->Get_Name(); }
|
||||
int Get_Current_Total_Calls( void ) { return m_pCurrentChild->Get_Total_Calls(); }
|
||||
float Get_Current_Total_Time( void ) { return m_pCurrentChild->Get_Total_Time(); }
|
||||
|
||||
// Access the current parent
|
||||
const char * Get_Current_Parent_Name( void ) { return m_pCurrentParent->Get_Name(); }
|
||||
int Get_Current_Parent_Total_Calls( void ) { return m_pCurrentParent->Get_Total_Calls(); }
|
||||
float Get_Current_Parent_Total_Time( void ) { return m_pCurrentParent->Get_Total_Time(); }
|
||||
CProfileObj * GetParentPtr() {return m_pCurrentParent;}
|
||||
CProfileObj * GetChildPtr() { return m_pCurrentChild;}
|
||||
protected:
|
||||
|
||||
CProfileObj * m_pCurrentParent;
|
||||
CProfileObj * m_pCurrentChild;
|
||||
|
||||
CProfileChecker( CProfileObj * start );
|
||||
friend class CProfileMgr;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** The Manager for the Profile system
|
||||
*/
|
||||
class CProfileMgr {
|
||||
public:
|
||||
static void StartProfile( const char * strName );
|
||||
static void StopProfile( void );
|
||||
|
||||
static void Reset( void );
|
||||
static void Increment_Frame_Counter( void );
|
||||
static int Get_Frame_Count_Since_Reset( void ) { return m_iFrameCounter; }
|
||||
static float Get_Time_Since_Reset( void );
|
||||
|
||||
static CProfileChecker *GetChecker( void ) { return new CProfileChecker( &m_Root ); }
|
||||
static void ReleaseChecker( CProfileChecker * iterator ) { SafeDelete(iterator); }
|
||||
|
||||
private:
|
||||
static CProfileObj m_Root;
|
||||
static CProfileObj *m_pCurrentNode;
|
||||
static int m_iFrameCounter;
|
||||
static __int64 m_iResetTime;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** ProfileSampleClass is a simple way to profile a function's scope
|
||||
** Use the PROFILE macro at the start of scope to time
|
||||
*/
|
||||
class CProfileSample {
|
||||
public:
|
||||
CProfileSample( const char * name )
|
||||
{
|
||||
CProfileMgr::StartProfile( name );
|
||||
}
|
||||
|
||||
~CProfileSample( void )
|
||||
{
|
||||
CProfileMgr::StopProfile();
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define PROFILE( name ) Caldron::Base::CProfileSample __profile( name )
|
||||
#else
|
||||
#define PROFILE( name )
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user