diff --git a/CMakePresets.json b/CMakePresets.json index feb7624772..0b692c61b3 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -25,15 +25,6 @@ } } }, - { - "name": "vc6-profile", - "displayName": "Windows 32bit VC6 Profile", - "hidden": false, - "inherits": "vc6", - "cacheVariables": { - "RTS_BUILD_OPTION_PROFILE": "ON" - } - }, { "name": "vc6-internal", "displayName": "Windows 32bit VC6 Internal", @@ -95,14 +86,6 @@ } } }, - { - "name": "win32-profile", - "inherits": "win32", - "displayName": "Windows 32bit Profile", - "cacheVariables": { - "RTS_BUILD_OPTION_PROFILE": "ON" - } - }, { "name": "win32-internal", "inherits": "win32", @@ -137,14 +120,6 @@ } } }, - { - "name": "win32-vcpkg-profile", - "inherits": "win32-vcpkg", - "displayName": "Windows 32bit VCPKG Profile", - "cacheVariables": { - "RTS_BUILD_OPTION_PROFILE": "ON" - } - }, { "name": "win32-vcpkg-internal", "inherits": "win32-vcpkg", @@ -181,12 +156,6 @@ "displayName": "Build Windows 32bit VC6 Internal", "description": "Build Windows 32bit VC6 Internal" }, - { - "name": "vc6-profile", - "configurePreset": "vc6-profile", - "displayName": "Build Windows 32bit VC6 Profile", - "description": "Build Windows 32bit VC6 Profile" - }, { "name": "vc6-debug", "configurePreset": "vc6-debug", @@ -207,13 +176,6 @@ "description": "Build Windows 32bit Internal", "configuration": "Release" }, - { - "name": "win32-profile", - "configurePreset": "win32-profile", - "displayName": "Build Windows 32bit Profile", - "description": "Build Windows 32bit Profile", - "configuration": "Release" - }, { "name": "win32-debug", "configurePreset": "win32-debug", @@ -235,13 +197,6 @@ "description": "Build Windows 32bit VCPKG Internal", "configuration": "Release" }, - { - "name": "win32-vcpkg-profile", - "configurePreset": "win32-vcpkg-profile", - "displayName": "Build Windows 32bit VCPKG Profile", - "description": "Build Windows 32bit VCPKG Profile", - "configuration": "Release" - }, { "name": "win32-vcpkg-debug", "configurePreset": "win32-vcpkg-debug", @@ -297,19 +252,6 @@ } ] }, - { - "name": "vc6-profile", - "steps": [ - { - "type": "configure", - "name": "vc6-profile" - }, - { - "type": "build", - "name": "vc6-profile" - } - ] - }, { "name": "win32", "steps": [ @@ -336,19 +278,6 @@ } ] }, - { - "name": "win32-profile", - "steps": [ - { - "type": "configure", - "name": "win32-profile" - }, - { - "type": "build", - "name": "win32-profile" - } - ] - }, { "name": "win32-debug", "steps": [ @@ -388,19 +317,6 @@ } ] }, - { - "name": "win32-vcpkg-profile", - "steps": [ - { - "type": "configure", - "name": "win32-vcpkg-profile" - }, - { - "type": "build", - "name": "win32-vcpkg-profile" - } - ] - }, { "name": "win32-vcpkg-debug", "steps": [ diff --git a/Core/Libraries/CMakeLists.txt b/Core/Libraries/CMakeLists.txt index 1658bfbb9e..f6d32f962d 100644 --- a/Core/Libraries/CMakeLists.txt +++ b/Core/Libraries/CMakeLists.txt @@ -1,9 +1,6 @@ # WW common libraries decended from earliest C&C games add_subdirectory(Source/WWVegas) -# profiling library -add_subdirectory(Source/profile) - # debugging library add_subdirectory(Source/debug) diff --git a/Core/Libraries/Include/rts/profile.h b/Core/Libraries/Include/rts/profile.h deleted file mode 100644 index 34cf2d4d46..0000000000 --- a/Core/Libraries/Include/rts/profile.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Include/rts/profile.h $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/03 11:55:26 $ -// -// (c) 2003 Electronic Arts -// -// Proxy header for profile module -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROXY_PROFILE_H // Include guard -#define PROXY_PROFILE_H - -#include "../../Source/profile/profile.h" - -#endif // PROXY_PROFILE_H diff --git a/Core/Libraries/Source/debug/debug.h b/Core/Libraries/Source/debug/debug.h index f353fe3e3b..a34571beb2 100644 --- a/Core/Libraries/Source/debug/debug.h +++ b/Core/Libraries/Source/debug/debug.h @@ -38,7 +38,6 @@ Generally speaking there are four different library variants: - Internal: all asserts/checks/logs, full optimizations (RTS_INTERNAL macro defined) - %Debug: all asserts/checks/logs, no optimizations (RTS_DEBUG macro defined) - - Profile: all asserts/checks/logs, full optimizations, profiling active (RTS_PROFILE macro defined) - Release: no asserts/checks/logs, full optimizations These variants will be broken down into separate features which @@ -49,7 +48,6 @@ HAS_ASSERTS HAS_LOGS HAS_OPT - HAS_PROFILE Internal
Y
@@ -62,12 +60,6 @@
Y
- - Profile -
Y
-
Y
-
Y
-
Y
Release
@@ -80,7 +72,6 @@ library variant: - Internal: XXXInternal.lib - %Debug: XXXDebug.lib - - Profile: XXXProfile.lib - Release: XXX.lib */ @@ -89,7 +80,7 @@ #endif // Define which libraries to use. -#if defined(RTS_INTERNAL) || defined(RTS_DEBUG) || defined(RTS_PROFILE) +#if defined(RTS_INTERNAL) || defined(RTS_DEBUG) # define HAS_ASSERTS # define HAS_LOGS #endif @@ -98,10 +89,6 @@ # define HAS_OPT #endif -#if defined(RTS_PROFILE) -# define HAS_PROFILE -#endif - // include all our public header files (use double quotes here) #include "debug_doc.h" #include "debug_macro.h" diff --git a/Core/Libraries/Source/debug/debug_debug.cpp b/Core/Libraries/Source/debug/debug_debug.cpp index 9423d0b754..7847086ace 100644 --- a/Core/Libraries/Source/debug/debug_debug.cpp +++ b/Core/Libraries/Source/debug/debug_debug.cpp @@ -1441,8 +1441,6 @@ void Debug::WriteBuildInfo(void) operator<<(" internal"); #elif defined(RTS_DEBUG) operator<<(" debug"); - #elif defined(RTS_PROFILE) - operator<<(" profile"); #else operator<<(" release"); #endif diff --git a/Core/Libraries/Source/profile/CMakeLists.txt b/Core/Libraries/Source/profile/CMakeLists.txt deleted file mode 100644 index bad4e7f94c..0000000000 --- a/Core/Libraries/Source/profile/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -set(PROFILE_SRC - "_pch.cpp" - "_pch.h" - "internal_cmd.h" - "internal_funclevel.h" - "internal_highlevel.h" - "internal_result.h" - "internal.h" - "profile_cmd.cpp" - "profile_doc.h" - "profile_funclevel.cpp" - "profile_funclevel.h" - "profile_highlevel.cpp" - "profile_highlevel.h" - "profile_result.cpp" - "profile_result.h" - "profile.cpp" - "profile.h" -) - -add_library(core_profile STATIC) - -target_sources(core_profile PRIVATE ${PROFILE_SRC}) - -target_include_directories(core_profile INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_link_libraries(core_profile PRIVATE - core_config - corei_always -) diff --git a/Core/Libraries/Source/profile/_pch.cpp b/Core/Libraries/Source/profile/_pch.cpp deleted file mode 100644 index b3ad7391e6..0000000000 --- a/Core/Libraries/Source/profile/_pch.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/_pch.cpp $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/03 11:55:26 $ -// -// (c) 2003 Electronic Arts -// -// Precompiled header (module internal) -////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" diff --git a/Core/Libraries/Source/profile/_pch.h b/Core/Libraries/Source/profile/_pch.h deleted file mode 100644 index 13d2bfaa8f..0000000000 --- a/Core/Libraries/Source/profile/_pch.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/_pch.h $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/03 11:55:26 $ -// -// (c) 2003 Electronic Arts -// -// Precompiled header (module internal) -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef _PCH_H // Include guard -#define _PCH_H - -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include - -#include "profile.h" -#include "internal.h" - -#endif // _PCH_H diff --git a/Core/Libraries/Source/profile/compile_doxygen.bat b/Core/Libraries/Source/profile/compile_doxygen.bat deleted file mode 100644 index d5aae7bfe4..0000000000 --- a/Core/Libraries/Source/profile/compile_doxygen.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off - -rem -rem This batch file generates DoxyGen info and compiles the separate -rem HTML files into CHMs. -rem -rem Assumptions: -rem ------------ -rem - doxygen installed and in path -rem - hhc (HTML Help Compiler) installed and in path -rem - dot (Graphviz package) installed and in path -rem -rem Both generated CHM files are then copied over to the -rem common DOC area. - -doxygen profile.dox -doxygen profile_priv.dox -cd doc\html -hhc index.hhp -copy index.chm ..\..\profile.chm -cd ..\html_priv -hhc index.hhp -copy index.chm ..\..\profile_priv.chm -cd ..\.. - -copy profile.chm ..\..\docs diff --git a/Core/Libraries/Source/profile/internal.h b/Core/Libraries/Source/profile/internal.h deleted file mode 100644 index 4ca27333cb..0000000000 --- a/Core/Libraries/Source/profile/internal.h +++ /dev/null @@ -1,158 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/internal.h $ -// $Author: mhoffe $ -// $Revision: #3 $ -// $DateTime: 2003/07/09 10:57:23 $ -// -// (c) 2003 Electronic Arts -// -// Internal header -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_H // Include guard -#define INTERNAL_H - -#include "../debug/debug.h" -#include "internal_funclevel.h" -#include "internal_highlevel.h" -#include "internal_cmd.h" -#include "internal_result.h" -#include "Utility/CppMacros.h" - -#if !(defined(_MSC_VER) && _MSC_VER < 1300) -#include -#include -#endif - -class ProfileFastCS -{ - ProfileFastCS(const ProfileFastCS&) CPP_11(= delete); - ProfileFastCS& operator=(const ProfileFastCS&) CPP_11(= delete); - - static HANDLE testEvent; - -#if defined(_MSC_VER) && _MSC_VER < 1300 - volatile unsigned m_Flag; - - void ThreadSafeSetFlag() - { - volatile unsigned& nFlag=m_Flag; - - #define ts_lock _emit 0xF0 - DASSERT(((unsigned)&nFlag % 4) == 0); - - __asm mov ebx, [nFlag] - __asm ts_lock - __asm bts dword ptr [ebx], 0 - __asm jc The_Bit_Was_Previously_Set_So_Try_Again - return; - - The_Bit_Was_Previously_Set_So_Try_Again: - // can't use SwitchToThread() here because Win9X doesn't have it! - if (testEvent) - ::WaitForSingleObject(testEvent,1); - __asm mov ebx, [nFlag] - __asm ts_lock - __asm bts dword ptr [ebx], 0 - __asm jc The_Bit_Was_Previously_Set_So_Try_Again - } - - void ThreadSafeClearFlag() - { - m_Flag=0; - } - -public: - ProfileFastCS(void): - m_Flag(0) - { - } -#else - - volatile std::atomic_flag Flag{}; - - void ThreadSafeSetFlag() - { - while (Flag.test_and_set(std::memory_order_acq_rel)) { - Flag.wait(true, std::memory_order_relaxed); - } - } - - void ThreadSafeClearFlag() - { - Flag.clear(std::memory_order_release); - Flag.notify_one(); - } - -public: - ProfileFastCS(void) {} - -#endif - - class Lock - { - Lock(const Lock&) CPP_11(= delete); - Lock& operator=(const Lock&) CPP_11(= delete); - - ProfileFastCS& CriticalSection; - - public: - Lock(ProfileFastCS& cs): - CriticalSection(cs) - { - CriticalSection.ThreadSafeSetFlag(); - } - - ~Lock() - { - CriticalSection.ThreadSafeClearFlag(); - } - }; - - friend class Lock; -}; - -void *ProfileAllocMemory(unsigned numBytes); -void *ProfileReAllocMemory(void *oldPtr, unsigned newSize); -void ProfileFreeMemory(void *ptr); - -__forceinline void ProfileGetTime(__int64 &t) -{ -#if defined(_MSC_VER) && _MSC_VER < 1300 - _asm - { - mov ecx,[t] - push eax - push edx - rdtsc - mov [ecx],eax - mov [ecx+4],edx - pop edx - pop eax - }; -#else - t = static_cast<__int64>(_rdtsc()); -#endif -} - -#endif // INTERNAL_H diff --git a/Core/Libraries/Source/profile/internal_cmd.h b/Core/Libraries/Source/profile/internal_cmd.h deleted file mode 100644 index f6e6f5bc2f..0000000000 --- a/Core/Libraries/Source/profile/internal_cmd.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/internal_cmd.h $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/09 10:57:23 $ -// -// (c) 2003 Electronic Arts -// -// Profile module command interface -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_CMD_H // Include guard -#define INTERNAL_CMD_H - -class ProfileCmdInterface: public DebugCmdInterface -{ - struct Factory - { - ProfileResultInterface* (*func)(int, const char * const *); - const char *name,*arg; - }; - - static unsigned numResIf; - static Factory *resIf; - - unsigned numResFunc; // optimizer bug: must be declared volatile! - ProfileResultInterface **resFunc; - -public: - ProfileCmdInterface(void): numResFunc(0), resFunc(0) {} - - static void AddResultFunction(ProfileResultInterface* (*func)(int, const char * const *), - const char *name, const char *arg); - void RunResultFunctions(void); - - virtual bool Execute(class Debug& dbg, const char *cmd, CommandMode cmdmode, - unsigned argn, const char * const * argv); - virtual void Delete(void) {} -}; - -#endif // INTERNAL_CMD_H diff --git a/Core/Libraries/Source/profile/internal_funclevel.h b/Core/Libraries/Source/profile/internal_funclevel.h deleted file mode 100644 index e9b6f2e3d7..0000000000 --- a/Core/Libraries/Source/profile/internal_funclevel.h +++ /dev/null @@ -1,362 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/internal_funclevel.h $ -// $Author: mhoffe $ -// $Revision: #4 $ -// $DateTime: 2003/08/14 13:43:29 $ -// -// (c) 2003 Electronic Arts -// -// Function level profiling (internal header) -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_FUNCLEVEL_H // Include guard -#define INTERNAL_FUNCLEVEL_H - -class ProfileFuncLevelTracer -{ - friend class ProfileCmdInterface; - - // can't copy this - ProfileFuncLevelTracer(const ProfileFuncLevelTracer&); - ProfileFuncLevelTracer& operator=(const ProfileFuncLevelTracer&); - -public: - enum - { - // # of simultaneous frame recordings - MAX_FRAME_RECORDS = 4 - }; - - /// simple unique unsigned/unsigned map - class UnsignedMap - { - UnsignedMap(const UnsignedMap&); - UnsignedMap& operator=(const UnsignedMap&); - - struct Entry - { - Entry *next; - unsigned val; - unsigned count; - }; - - enum - { - // do not make this number too large - // a single function uses approx HASH_SIZE*20 bytes! - HASH_SIZE = 131 - }; - - Entry *e; - unsigned alloc,used; - Entry *hash[HASH_SIZE]; - bool writeLock; - - void _Insert(unsigned at, unsigned val, int countAdd); - - public: - UnsignedMap(void); - ~UnsignedMap(); - - void Clear(void); - void Insert(unsigned val, int countAdd); - unsigned Enumerate(int index); - unsigned GetCount(int index); - void Copy(const UnsignedMap &src); - void MixIn(const UnsignedMap &src); - }; - - /// profile entry - struct Profile - { - /// call count - __int64 callCount; - - /// pure time - __int64 tickPure; - - /// total time - __int64 tickTotal; - - /// caller list - UnsignedMap caller; - - /// tracer for this profile - ProfileFuncLevelTracer *tracer; - - void Copy(const Profile &src) - { - callCount=src.callCount; - tickPure=src.tickPure; - tickTotal=src.tickTotal; - caller.Copy(src.caller); - } - - void MixIn(const Profile &src) - { - callCount+=src.callCount; - tickPure+=src.tickPure; - tickTotal+=src.tickTotal; - caller.MixIn(src.caller); - } - }; - - /// map of profiles - class ProfileMap - { - ProfileMap(const ProfileMap&); - ProfileMap& operator=(const ProfileMap&); - - struct List - { - List *next; - int frame; - Profile p; - }; - - List *root,**tail; - - public: - ProfileMap(void); - ~ProfileMap(); - - Profile *Find(int frame); - void Append(int frame, const Profile &p); - void MixIn(int frame, const Profile &p); - }; - - /// function entry (map address -> Function) - struct Function - { - /// address of this function - unsigned addr; - - /// global profile - Profile glob; - - /// profile for current frame(s) - Profile cur[MAX_FRAME_RECORDS]; - - /// frame based profiles - ProfileMap frame; - - /// current call depth (for recursion) - int depth; - - /// function source - char *funcSource; - - /// function source line - unsigned funcLine; - - /// function name - char *funcName; - - Function(ProfileFuncLevelTracer *tr) - { - glob.tracer=tr; - for (int k=0;knext) - if (e->val==val) - { - e->count+=countAdd; - return; - } - _Insert(at,val,countAdd); -} - -inline ProfileFuncLevelTracer::Function *ProfileFuncLevelTracer::FunctionMap::Find(unsigned addr) -{ - for (Entry *e=hash[(addr/16)%HASH_SIZE];e;e=e->next) - if (e->funcPtr->addr==addr) - return e->funcPtr; - return NULL; -} - -#endif // INTERNAL_FUNCLEVEL_H diff --git a/Core/Libraries/Source/profile/internal_highlevel.h b/Core/Libraries/Source/profile/internal_highlevel.h deleted file mode 100644 index 48d202ec23..0000000000 --- a/Core/Libraries/Source/profile/internal_highlevel.h +++ /dev/null @@ -1,247 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/internal_highlevel.h $ -// $Author: mhoffe $ -// $Revision: #2 $ -// $DateTime: 2003/08/14 13:43:29 $ -// -// (c) 2003 Electronic Arts -// -// High level profiling (internal header) -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_HIGHLEVEL_H // Include guard -#define INTERNAL_HIGHLEVEL_H - -/// an internal high level profile ID -class ProfileId -{ - ProfileId(const ProfileId&); - ProfileId& operator=(const ProfileId&); - -public: - /** - Creates a new high level profile ID. - - \param name profile name - \param descr descriptive name - \param unit unit name - \param precision number of decimal places to show - \param exp10 10 base exponent (used for scaleing) - */ - ProfileId(const char *name, const char *descr, const char *unit, int precision, int exp10); - - /** - Retrieves the first profile ID. - - \return first profile ID - */ - static ProfileId *GetFirst(void) { return first; } - - /** - Retrieves next profile ID. - - \return next profile ID, NULL if none - */ - ProfileId *GetNext(void) const { return m_next; } - - /** - Retrieves name of the profile ID. - - \return profile ID name - */ - const char *GetName(void) const { return m_name; } - - /** - Retrieves unit name of the profile ID. - - \return profile ID unit name - */ - const char *GetUnit(void) const { return m_unit?m_unit:""; } - - /** - Retrieves description of the profile ID. - - \return profile description - */ - const char *GetDescr(void) const { return m_descr?m_descr:""; } - - /** - Increments the profile value. - - \param add add value - */ - void Increment(double add); - - /** - Sets a new maximum value. - - \param max new maximum value - */ - void Maximum(double max); - - /** - Returns current value, internally resetting it. - - \return current value - */ - double GetCurrentValue(void) - { - double help=m_curVal; - m_curVal=0.; - return help; - } - - /** - Returns total value - - \return total value - */ - double GetTotalValue(void) const - { - return m_totalVal; - } - - /** - Returns value at the given frame. - - \param frame frame number - \param value value at frame - \return true if frame found, false if not - */ - bool GetFrameValue(unsigned frame, double &value) const - { - if (frame<(unsigned)m_firstFrame|| - frame>=(unsigned)curFrame) - return false; - value=m_recFrameVal[frame-m_firstFrame]; - return true; - } - - /** - Translate given numeric value into a string, using an internal temp buffer. - - \param v value - \return given numeric value as string - */ - const char *AsString(double v) const; - - /** - Shutdown function. - */ - static void Shutdown(void); - - /** - Starts frame based profiling, starts a new frame. - */ - static int FrameStart(void); - - /** - Ends frame based profiling. - */ - static void FrameEnd(int which, int mixIndex); - - /** - Clears all total values. - */ - static void ClearTotals(void) - { - for (ProfileId *cur=first;cur;cur=cur->m_next) - cur->m_totalVal=0.; - } - -private: - /** - ProfileId's can't be destructed. - */ - ~ProfileId() {} - - enum - { - /// # of simultaneous frame recordings - MAX_FRAME_RECORDS = 4, - - /// size of internal string buffer - STRING_BUFFER_SIZE = 1024 - }; - - /// possible value modes - enum ValueMode - { - Unknown, - ModeIncrement, - ModeMaximum - }; - - /// first profile ID - static ProfileId *first; - - /// next profile ID - ProfileId *m_next; - - /// profile name - char *m_name; - - /// profile description - char *m_descr; - - /// profile unit - char *m_unit; - - /// number of decimal places to show - int m_precision; - - /// 10 base exponent (used for scaleing) - int m_exp10; - - /// current value - double m_curVal; - - /// total value - double m_totalVal; - - /// frame values - double m_frameVal[MAX_FRAME_RECORDS]; - - /// list of recorded frame values - double *m_recFrameVal; - - /// index of first recorded frame - int m_firstFrame; - - /// value mode - ValueMode m_valueMode; - - /// current frame - static int curFrame; - - /// bit mask, currently recording which cur[] entries? - static unsigned frameRecordMask; - - /// internal string buffer - static char stringBuf[STRING_BUFFER_SIZE]; - - /// next unused char in string buffer - static unsigned stringBufUnused; -}; - -#endif // INTERNAL_HIGHLEVEL_H diff --git a/Core/Libraries/Source/profile/internal_result.h b/Core/Libraries/Source/profile/internal_result.h deleted file mode 100644 index 3e952fa040..0000000000 --- a/Core/Libraries/Source/profile/internal_result.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/internal_result.h $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/09 10:57:23 $ -// -// (c) 2003 Electronic Arts -// -// Internal result functions -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_RESULT_H // Include guard -#define INTERNAL_RESULT_H - -/// \brief Simple CSV format flat file result function, for all threads. -class ProfileResultFileCSV: public ProfileResultInterface -{ - ProfileResultFileCSV(void) {} - - void WriteThread(ProfileFuncLevel::Thread &thread); - -public: - static ProfileResultInterface *Create(int argn, const char * const *); - virtual const char *GetName(void) const { return "file_csv"; } - virtual void WriteResults(void); - virtual void Delete(void); -}; - -/** - \brief Write out DOT file for calling hierarchy. - - The frame name and the file name must be specified when creating an - instance of this result function. The result function will always pick - the thread with the highest function count (which is usually the - main thread). - - \note A DOT file is used with the DOT tool from the GraphViz package - for generating directed graphs, e.g. by issuing dot -Tgif -ograph.gif profile.dot -*/ -class ProfileResultFileDOT: public ProfileResultInterface -{ -public: - enum - { - MAX_FUNCTIONS_PER_FILE = 200 - }; - - /** - \brief Creates a class instance. - - \param fileName name of DOT file to generate (defaults to profile.dot) - \param frameName name of frame to use (NULL for global) - \param foldThreshold if the number of functions exceeds the given threshold - then all functions belonging to the same source file - will be folded into a single entry - \return new instance - */ - static ProfileResultInterface *Create(int argn, const char * const *); - - virtual const char *GetName(void) const { return "file_dot"; } - virtual void WriteResults(void); - virtual void Delete(void); - -private: - - ProfileResultFileDOT(const char *fileName, const char *frameName, int foldThreshold); - - struct FoldHelper - { - FoldHelper *next; - const char *source; - ProfileFuncLevel::Id id[MAX_FUNCTIONS_PER_FILE]; - unsigned numId; - bool mark; - }; - - char *m_fileName; - char *m_frameName; - int m_foldThreshold; -}; - -#endif // INTERNAL_RESULT_H diff --git a/Core/Libraries/Source/profile/profile.cpp b/Core/Libraries/Source/profile/profile.cpp deleted file mode 100644 index 1e65d6b926..0000000000 --- a/Core/Libraries/Source/profile/profile.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile.cpp $ -// $Author: mhoffe $ -// $Revision: #6 $ -// $DateTime: 2003/08/14 13:43:29 $ -// -// (c) 2003 Electronic Arts -// -// Profile module main code -////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" -#include -#include "mmsystem.h" - -// yuk, I'm doing this so weird because the destructor -// of cmd must never be called... -static ProfileCmdInterface &cmd=*(ProfileCmdInterface *)new - (ProfileAllocMemory(sizeof(ProfileCmdInterface))) ProfileCmdInterface(); - -// we have this here so that our command interface will always -// be linked in as well... -static bool __RegisterDebugCmdGroup_Profile=Debug::AddCommands("profile",&cmd); - -void *ProfileAllocMemory(unsigned numBytes) -{ - HGLOBAL h=GlobalAlloc(GMEM_FIXED,numBytes); - if (!h) - DCRASH_RELEASE("Debug mem alloc failed"); - return (void *)h; -} - -void *ProfileReAllocMemory(void *oldPtr, unsigned newSize) -{ - // Windows doesn't like ReAlloc with NULL handle/ptr... - if (!oldPtr) - return newSize?ProfileAllocMemory(newSize):0; - - // Shrinking to 0 size is basically freeing memory - if (!newSize) - { - GlobalFree((HGLOBAL)oldPtr); - return 0; - } - - // now try GlobalReAlloc first - HGLOBAL h=GlobalReAlloc((HGLOBAL)oldPtr,newSize,0); - if (!h) - { - // this failed (Windows doesn't like ReAlloc'ing larger - // fixed memory blocks) - go with Alloc/Free instead - h=GlobalAlloc(GMEM_FIXED,newSize); - if (!h) - DCRASH_RELEASE("Debug mem realloc failed"); - unsigned oldSize=GlobalSize((HGLOBAL)oldPtr); - memcpy((void *)h,oldPtr,oldSizenext) - { - if (SimpleMatch(range,cur->pattern)) - active=cur->isActive; - } - - if (active) - { -#ifdef RTS_PROFILE - m_frameNames[k].funcIndex=ProfileFuncLevelTracer::FrameStart(); - DASSERT(m_frameNames[k].funcIndex>=0); -#endif - m_frameNames[k].highIndex=ProfileId::FrameStart(); - DASSERT(m_frameNames[k].highIndex>=0); - } - else - { - m_frameNames[k].funcIndex=-1; - m_frameNames[k].highIndex=-1; - } -} - -void Profile::AppendRange(const char *range) -{ - // set default - if (!range) - range="frame"; - - // known name? - unsigned k=0; - for (;knext) - { - if (SimpleMatch(range,cur->pattern)) - active=cur->isActive; - } - - if (active) - { -#ifdef RTS_PROFILE - m_frameNames[k].funcIndex=ProfileFuncLevelTracer::FrameStart(); - DASSERT(m_frameNames[k].funcIndex>=0); -#endif - m_frameNames[k].highIndex=ProfileId::FrameStart(); - DASSERT(m_frameNames[k].highIndex>=0); - } - else - { - m_frameNames[k].funcIndex=-1; - m_frameNames[k].highIndex=-1; - } -} - -void Profile::StopRange(const char *range) -{ - // set default - if (!range) - range="frame"; - - // known name? - unsigned k=0; - for (;k=0 || -#endif - m_frameNames[k].highIndex>=0 - ) - { - // add to list of known frames? - int atIndex; - if (!m_frameNames[k].doAppend|| - m_frameNames[k].lastGlobalIndex<0) - { - atIndex=-1; - m_frameNames[k].lastGlobalIndex=m_rec; - m_recNames=(char **)ProfileReAllocMemory(m_recNames,(m_rec+1)*sizeof(char *)); - m_recNames[m_rec]=(char *)ProfileAllocMemory(strlen(range)+1+6); - wsprintf(m_recNames[m_rec++],"%s:%i",range,++m_frameNames[k].frames); - } - else - atIndex=m_frameNames[k].lastGlobalIndex; -#ifdef RTS_PROFILE - if (m_frameNames[k].funcIndex>=0) - ProfileFuncLevelTracer::FrameEnd(m_frameNames[k].funcIndex,atIndex); - if (m_frameNames[k].highIndex>=0) -#endif - ProfileId::FrameEnd(m_frameNames[k].highIndex,atIndex); - } -} - -bool Profile::IsEnabled(void) -{ - for (unsigned k=0;k=m_rec?NULL:m_recNames[frame]; -} - -void Profile::ClearTotals(void) -{ -#ifdef RTS_PROFILE - ProfileFuncLevelTracer::ClearTotals(); -#endif - ProfileId::ClearTotals(); -} - -_int64 Profile::GetClockCyclesPerSecond(void) -{ - return m_clockCycles; -} - -void Profile::AddResultFunction(ProfileResultInterface* (*func)(int, const char * const *), - const char *name, const char *arg) -{ - ProfileCmdInterface::AddResultFunction(func,name,arg); -} - -bool Profile::SimpleMatch(const char *str, const char *pattern) -{ - DASSERT(str); - DASSERT(pattern); - while (*str&&*pattern) - { - if (*pattern=='*') - { - pattern++; - while (*str) - if (SimpleMatch(str++,pattern)) - return true; - return *str==*pattern; - } - else - { - if (*str++!=*pattern++) - return false; - } - } - - return *str==*pattern; -} - -static void ProfileShutdown(void) -{ -#ifdef RTS_PROFILE - ProfileFuncLevelTracer::Shutdown(); -#endif - ProfileId::Shutdown(); - - DLOG("CPU speed is " << unsigned(Profile::GetClockCyclesPerSecond()) << " Hz.\n"); - - cmd.RunResultFunctions(); -} - -int profileTracerInit=atexit(ProfileShutdown); diff --git a/Core/Libraries/Source/profile/profile.dox b/Core/Libraries/Source/profile/profile.dox deleted file mode 100644 index 8f004994c8..0000000000 --- a/Core/Libraries/Source/profile/profile.dox +++ /dev/null @@ -1,208 +0,0 @@ -# Doxyfile 1.3.1 - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = "EA/Profile module" -PROJECT_NUMBER = -OUTPUT_DIRECTORY = doc/ -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = YES -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -HIDE_UNDOC_MEMBERS = YES -HIDE_UNDOC_CLASSES = YES -HIDE_FRIEND_COMPOUNDS = YES -HIDE_IN_BODY_DOCS = YES -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = YES -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = YES -SHORT_NAMES = NO -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -GENERATE_TODOLIST = NO -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ALIASES = "todo_opt=\todo" -ALIASES += "todo_urgent=\todo" -ALIASES += "todo_feature=\todo" -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -SHOW_USED_FILES = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = ./ -FILE_PATTERNS = profile*.h -RECURSIVE = NO -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -VERBATIM_HEADERS = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = YES -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = YES -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = YES -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = RTS_DEBUG \ - DOXYGEN -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = NO -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -DOT_IMAGE_FORMAT = png -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 0 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO -CGI_NAME = search.cgi -CGI_URL = -DOC_URL = -DOC_ABSPATH = -BIN_ABSPATH = /usr/local/bin/ -EXT_DOC_PATHS = diff --git a/Core/Libraries/Source/profile/profile.h b/Core/Libraries/Source/profile/profile.h deleted file mode 100644 index d1c6fccb17..0000000000 --- a/Core/Libraries/Source/profile/profile.h +++ /dev/null @@ -1,214 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile.h $ -// $Author: mhoffe $ -// $Revision: #4 $ -// $DateTime: 2003/08/14 13:43:29 $ -// -// (c) 2003 Electronic Arts -// -// Profiling module -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROFILE_H // Include guard -#define PROFILE_H - -#if defined(RTS_DEBUG) && defined(RTS_INTERNAL) - #error "Only either RTS_DEBUG or RTS_INTERNAL should ever be defined" -#endif - -// include all our public header files (use double quotes here) -#include "profile_doc.h" -#include "profile_highlevel.h" -#include "profile_funclevel.h" -#include "profile_result.h" - -/** - \brief Functions common to both profilers. -*/ -class Profile -{ - friend class ProfileCmdInterface; - - // nobody can construct this class - Profile(); - -public: - - /** - \brief Starts range recording. - - \param range name of range to record, ==NULL for "frame" - */ - static void StartRange(const char *range=0); - - /** - \brief Appends profile data to the last recorded frame - of the given range. - - \param range name of range to record, ==NULL for "frame" - */ - static void AppendRange(const char *range=0); - - /** - \brief Stops range recording. - - \note After this call the recorded range data will be available - as a new range frame. - - \param range name of range to record, ==NULL for "frame" - */ - static void StopRange(const char *range=0); - - /** - \brief Determines if any range recording is enabled or not. - - \return true if range profiling is enabled, false if not - */ - static bool IsEnabled(void); - - /** - \brief Determines the number of known (recorded) range frames. - - Note that if function level profiling is enabled then the number - of recorded high level frames is the same as the number of recorded - function level frames. - - \return number of recorded range frames - */ - static unsigned GetFrameCount(void); - - /** - \brief Determines the range name of a recorded range frame. - - \note A unique number will be added to the frame name, separated by - a ':', e.g. 'frame:3' - - \param frame number of recorded frame - \return range name - */ - static const char *GetFrameName(unsigned frame); - - /** - \brief Resets all 'total' counter values to 0. - - This function does not change any recorded frames. - */ - static void ClearTotals(void); - - /** - \brief Determines number of CPU clock cycles per second. - - \note This value is cached internally so this function is - quite fast. - - \return number of CPU clock cycles per second - */ - static _int64 GetClockCyclesPerSecond(void); - - /** - \brief Add the given result function interface. - - \param func factory function - \param name factory name - \param arg description of optional parameters the factory function recognizes - */ - static void AddResultFunction(ProfileResultInterface* (*func)(int, const char * const *), - const char *name, const char *arg); - -private: - /** \internal - - \brief Simple recursive pattern matcher. - - \param str string to match - \param pattern pattern, only wildcard valid is '*' - \return true if string matches pattern, false if not - */ - static bool SimpleMatch(const char *str, const char *pattern); - - /// known frame names - struct FrameName - { - /// frame name - char *name; - - /// number of recorded frames for this name - unsigned frames; - - /// are we currently recording? - bool isRecording; - - /// should current frame be appended to last frame with same name - bool doAppend; - - /// internal index for function level profiler - int funcIndex; - - /// internal index for high level profiler - int highIndex; - - /// global frame number of last recorded frame for this range, -1 if none - int lastGlobalIndex; - }; - - /// \internal pattern list entry - struct PatternListEntry - { - /// next entry - PatternListEntry *next; - - /// active (true) or inactive (false)? - bool isActive; - - /// pattern itself (dynamic allocated memory) - char *pattern; - }; - - /** \internal - - First pattern list list entry. A singly linked list is - okay for this because checking patterns is a costly - operation anyway and is therefore cached. - */ - static PatternListEntry *firstPatternEntry; - - /// \internal last pattern list entry for fast additions to list at end - static PatternListEntry *lastPatternEntry; - - /// number of recorded frames - static unsigned m_rec; - - /// names of recorded frames - static char **m_recNames; - - /// number of known frame names - static unsigned m_names; - - /// list of known frame names - static FrameName *m_frameNames; - - /// CPU clock cycles/second - static _int64 m_clockCycles; -}; - -#endif // PROFILE_H diff --git a/Core/Libraries/Source/profile/profile_cmd.cpp b/Core/Libraries/Source/profile/profile_cmd.cpp deleted file mode 100644 index e138bab3f8..0000000000 --- a/Core/Libraries/Source/profile/profile_cmd.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile_cmd.cpp $ -// $Author: mhoffe $ -// $Revision: #2 $ -// $DateTime: 2003/08/12 15:05:00 $ -// -// (c) 2003 Electronic Arts -// -// Profile module command interface -////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" - -unsigned ProfileCmdInterface::numResIf; -ProfileCmdInterface::Factory *ProfileCmdInterface::resIf; - -void ProfileCmdInterface::AddResultFunction(ProfileResultInterface* (*func)(int, const char * const *), - const char *name, const char *arg) -{ - DFAIL_IF(!func) return; - DFAIL_IF(!name) return; - for (unsigned k=0;kWriteResults(); - resFunc[k]->Delete(); - } -} - -bool ProfileCmdInterface::Execute(class Debug& dbg, const char *cmd, CommandMode cmdmode, - unsigned argn, const char * const * argv) -{ - // just for convenience... - bool normalMode=cmdmode==CommandMode::Normal; - - if (!strcmp(cmd,"help")) - { - if (!normalMode) - return true; - - if (!argn) - { - dbg << "profile group help:\n" - " result, caller, clear, add, view\n"; - return true; - } - else if (!strcmp(argv[0],"result")) - { - dbg << "result\n\n" - "Shows the list of available result functions and their\n" - "optional parameters.\n" - "\n" - "result [ .. ]\n\n" - "Adds the given result function to be executed on program\n" - "exit.\n"; - } - else if (!strcmp(argv[0],"caller")) - { - dbg << "caller [ (+|-) ]\n\n" - "Enables/disables recording of caller information while\n" - "performing function level profiling. Turned off by default\n" - "since CPU hit is non-zero.\n"; - } - else if (!strcmp(argv[0],"clear")) - { - dbg << "clear\n\n" - "Clears the profile inclusion/exclusion list.\n"; - return true; - } - else if (!strcmp(argv[0],"add")) - { - dbg << "add (+|-) \n" - "\n" - "Adds a pattern to the profile list. By default all\n" - "profile ranges are disabled. Each new range is then checked\n" - "against all pattern in this list. If a match is found the\n" - "active/inactive state is modified accordingly (+ for active,\n" - "- for inactive). The final state is always the last match."; - return true; - } - else if (!strcmp(argv[0],"view")) - { - dbg << "view\n\n" - "Shows the active pattern list.\n"; - return true; - } - return false; - } - - // command: result - if (!strcmp(cmd,"result")) - { - if (!argn) - { - unsigned k=0; - for (;kpattern,pattern)) - { - // remove this entry - Profile::PatternListEntry *cur=*entryPtr; - *entryPtr=cur->next; - ProfileFreeMemory(cur->pattern); - ProfileFreeMemory(cur); - } - else - entryPtr=&((*entryPtr)->next); - } - - // must fixup lastPatternEntry now - if (Profile::firstPatternEntry) - { - Profile::PatternListEntry *cur=Profile::firstPatternEntry; - for (;cur->next;cur=cur->next); - Profile::lastPatternEntry=cur; - } - else - Profile::lastPatternEntry=NULL; - return true; - } - - // command: add - if (!strcmp(cmd,"add")) - { - // add a pattern - if (argn<2) - dbg << "Please specify mode and pattern"; - else - { - // alloc new pattern entry - Profile::PatternListEntry *cur=(Profile::PatternListEntry *) - ProfileAllocMemory(sizeof(Profile::PatternListEntry)); - - // init - cur->next=NULL; - cur->isActive=*argv[0]=='+'; - cur->pattern=(char *)ProfileAllocMemory(strlen(argv[1])+1); - strcpy(cur->pattern,argv[1]); - - // add to list - if (Profile::lastPatternEntry) - Profile::lastPatternEntry->next=cur; - else - Profile::firstPatternEntry=cur; - Profile::lastPatternEntry=cur; - } - return true; - } - - // command: view - if (!strcmp(cmd,"view")) - { - // show list of defined patterns - for (Profile::PatternListEntry *cur=Profile::firstPatternEntry;cur;cur=cur->next) - dbg << (cur->isActive?"+ ":"- ") << cur->pattern << "\n"; - return true; - } - - // unknown command - return false; -} diff --git a/Core/Libraries/Source/profile/profile_doc.h b/Core/Libraries/Source/profile/profile_doc.h deleted file mode 100644 index 51942fe595..0000000000 --- a/Core/Libraries/Source/profile/profile_doc.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile_doc.h $ -// $Author: mhoffe $ -// $Revision: #3 $ -// $DateTime: 2003/07/09 10:57:23 $ -// -// (c) 2003 Electronic Arts -// -// additional Doxygen module documentation -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROFILE_DOC_H // Include guard -#define PROFILE_DOC_H - -// This generates a small main page for Doxygen if a module only -// documentation is built. -#ifndef DOXYGEN_GLOBAL_DOC -/** - \mainpage %Profile module - - The following pages contain the most useful information: - - \ref module_profile - - \ref profile_cmd - - \internal This is the internal module documentation meant only for - programmers who are working on the module internals. -*/ -#endif - -/** - \page module_profile Profile module overview - - \section overview Overview - - The profile module contains the following logical groups: - - high level hierarchical timer and logical profiling (frame based and global) - - function level hierarchical timer based profiling (frame based and global) - - Profiling data can be accessed in different ways: - - using debug commands to query for profiling data - - using debug commands to set up a write-to-file mode for profile data - - using the C++ interface herein - - \section highlevel High Level Profiling - - High level profiling can be done both timer based and logical. An example - for a logical profile would be the number of texture changes per frame - or the number of triangles rendered. - - The hierarchy is enforced by using a hierarchical naming scheme. For - timer based profiles this hierachy is build automatically, for - logical profiles each profile must be named accordingly when being created. - - High level profiling is available in all build configurations. All - high level profile functions are optimized for speed (at least while - profiling is disabled) so that there is an almost zero cost for - having profiling in all configurations. - - \section funclevel Function Level Profiling - - Function level profiling determines general call statistics, e.g. call - count per frame/total, time spent in function, time per call, time - spend in function and children, etc. - - Function level profiling is available in the 'profile' build configuration - only since it relies on the fact that the compiler generates '_penter' - function calls at the beginning of each function. - - \section frames Profile frames - - Instead of just providing frame based profiles this module has the concept - of profile ranges. A range is a period of time specified by a Begin and - and End function call. All data within this range is recorded as a range. - - It is possible to capture to more than one active range at the same time. - - Ordinary frame capturing can be achieved by recording a range back-to-back. - - Using ranges makes it very easy to profile logically connected events, e.g. - profiling a level load time. - - \section cmdif Command interface - - This module provides a Debug Module command interface called 'profile'. - The commands in this command interface are basically: - - enabling/disabling profiles, either for frame counts or ranges - - querying of current profile data - - enabling write-to-file mode for profile data -*/ - -/** - \page profile_cmd Profile commands - - Notation used: - - [ abc ] means that 'abc' may or may not be specified - - { abc } means that 'abc' may be specified any number of times (or not at all) - - (a|b|c) means that either 'a', 'b' or 'c' must be specified once - - The following commands exist (group: profile): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CommandParametersDescription
result[ \ [ \ .. \ ] ] - Without parameters this command shows the list of available - result functions and their optional parameters. - - If however a result function name is given then this result - function (and the given parameters) are added to the list of - active result functions. They are executed on program exit and - used to generate e.g. a CSV file containing the profile results. -
caller[ (+|-) ] - Enables/disables recording of caller information while - performing function level profiling. Turned off by default - since CPU hit is non-zero. -
clear - Clears the profile inclusion/exclusion list. -
add(+|-) \ - Adds a pattern to the profile list. By default all - profile ranges are disabled. Each new range is then checked - against all pattern in this list. If a match is found the - active/inactive state is modified accordingly (+ for active, - - for inactive). The final state is always the last match. -
view - Shows the active pattern list. -
-
- -*/ - -#endif // PROFILE_DOC_H diff --git a/Core/Libraries/Source/profile/profile_funclevel.cpp b/Core/Libraries/Source/profile/profile_funclevel.cpp deleted file mode 100644 index 070de422a5..0000000000 --- a/Core/Libraries/Source/profile/profile_funclevel.cpp +++ /dev/null @@ -1,793 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile_funclevel.cpp $ -// $Author: mhoffe $ -// $Revision: #4 $ -// $DateTime: 2003/08/14 13:43:29 $ -// -// (c) 2003 Electronic Arts -// -// Function level profiling -////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" -#include "../debug/debug.h" -#include - -#ifdef HAS_PROFILE - -// TLS index (-1 if not yet initialized) -static int TLSIndex=-1; - -// our own fast critical section -static ProfileFastCS cs; - -// Unfortunately VC 6 doesn't support _pleave (or _pexit) so -// we have to come up with our own type of implementation here... -static void __declspec(naked) _pleave(void) -{ - ProfileFuncLevelTracer *p; - unsigned curESP,leaveAddr; - - _asm - { - push ebp // this will be overwritten down there... - push ebp // setup standard stack frame - push eax - mov ebp,esp - mov eax,esp - sub esp,3*4 // 3 local DWord vars - pushad - mov [curESP],eax - } - - curESP+=8; - p=(ProfileFuncLevelTracer *)TlsGetValue(TLSIndex); - leaveAddr=p->Leave(curESP); - *(unsigned *)(curESP)=leaveAddr; - - _asm - { - popad - add esp,3*4 // must match sub esp above - pop eax - pop ebp - ret - } -} - -extern "C" void __declspec(naked) _cdecl _penter(void) -{ - unsigned callerFunc,ESPonReturn,callerRet; - ProfileFuncLevelTracer *p; - - _asm - { - push ebp - push eax - mov ebp,esp - mov eax,esp - sub esp,4*4 // 4 local DWord vars - pushad - - // calc return address - add eax,4+4 // account for push ebp and push eax - mov ebx,[eax] // grab return address - mov [callerFunc],ebx - - // get some more stuff - add eax,4 - mov [ESPonReturn],eax - mov ebx,[eax] - mov [callerRet],ebx - - // jam in our exit code - mov dword ptr [eax],offset _pleave - } - - // do we need a new stack tracer? - if (TLSIndex==-1) - TLSIndex=TlsAlloc(); - p=(ProfileFuncLevelTracer *)TlsGetValue(TLSIndex); - if (!p) - { - p=(ProfileFuncLevelTracer *)ProfileAllocMemory(sizeof(ProfileFuncLevelTracer)); - new (p) ProfileFuncLevelTracer; - TlsSetValue(TLSIndex,p); - } - - // enter function - p->Enter(callerFunc-5,ESPonReturn,callerRet); - - // cleanup - _asm - { - popad - add esp,4*4 // must match sub esp above - pop eax - pop ebp - ret - } -} - -ProfileFuncLevelTracer *ProfileFuncLevelTracer::head=NULL; -bool ProfileFuncLevelTracer::shuttingDown=false; -int ProfileFuncLevelTracer::curFrame=0; -unsigned ProfileFuncLevelTracer::frameRecordMask; -bool ProfileFuncLevelTracer::recordCaller=false; - -ProfileFuncLevelTracer::ProfileFuncLevelTracer(void): - stack(NULL), usedStack(0), totalStack(0), maxDepth(0) -{ - ProfileFastCS::Lock lock(cs); - - next=head; - head=this; -} - -ProfileFuncLevelTracer::~ProfileFuncLevelTracer() -{ - // yes, I know we leak... -} - -void ProfileFuncLevelTracer::Enter(unsigned addr, unsigned esp, unsigned ret) -{ - // must stack grow? - if (usedStack>=totalStack) - stack=(StackEntry *)ProfileReAllocMemory(stack,(totalStack+=100)*sizeof(StackEntry)); - - // save info - Function *f=func.Find(addr); - if (!f) - { - // new function - f=(Function *)ProfileAllocMemory(sizeof(Function)); - new (f) Function(this); - f->addr=addr; - f->glob.callCount=f->glob.tickPure=f->glob.tickTotal=0; - for (int i=0;icur[i].callCount=f->cur[i].tickPure=f->cur[i].tickTotal=0; - f->depth=0; - func.Insert(f); - } - - StackEntry &s=stack[usedStack++]; - s.func=f; - s.esp=esp; - s.retVal=ret; - ProfileGetTime(s.tickEnter); - s.tickSubTime=0; - f->depth++; - - // new max depth? - if (usedStack>=maxDepth) - maxDepth=usedStack; - - DLOG_GROUP(profile_stack,Debug::RepeatChar(' ',usedStack-1) - << Debug::Hex() << this - << " Enter " << Debug::Width(8) << addr - << " ESP " << Debug::Width(8) << esp - << " return " << Debug::Width(8) << ret - << " level " << Debug::Dec() << usedStack - ); -} - -unsigned ProfileFuncLevelTracer::Leave(unsigned esp) -{ - // get current "time" - __int64 cur; - ProfileGetTime(cur); - - while (usedStack>0) - { - // leave current function - usedStack--; - StackEntry &s=stack[usedStack], - &sPrev=stack[usedStack-1]; - - Function *f=s.func; - - // decrease call depth - // note: add global time only if call depth is 0 - f->depth--; - - // insert caller - if (recordCaller&&usedStack) - f->glob.caller.Insert(sPrev.func->addr,1); - - // inc call counter - f->glob.callCount++; - - // add total time - __int64 delta=cur-s.tickEnter; - if (!f->depth) - f->glob.tickTotal+=delta; - - // add pure time - f->glob.tickPure+=delta-s.tickSubTime; - - // add sub time for higher function - if (usedStack) - sPrev.tickSubTime+=delta; - - // frame based profiling? - if (frameRecordMask) - { - unsigned mask=frameRecordMask; - for (unsigned i=0;i0) - f->cur[i].caller.Insert(sPrev.func->addr,1); - f->cur[i].callCount++; - if (!f->depth) - f->cur[i].tickTotal+=delta; - f->cur[i].tickPure+=delta-s.tickSubTime; - } - if (!(mask>>=1)) - break; - } - } - - // exit if address match (somewhat...) - if (s.esp==esp) - break; - - // catching those nasty ret... - if (s.espnext) - p->FrameEnd(i,-1); - } -} - -int ProfileFuncLevelTracer::FrameStart(void) -{ - ProfileFastCS::Lock lock(cs); - - unsigned i=0; - for (;inext) - { - Function *f; - for (int k=0;(f=p->func.Enumerate(k))!=NULL;k++) - { - Profile &p=f->cur[i]; - p.caller.Clear(); - p.callCount=p.tickPure=p.tickTotal=0; - } - } - - frameRecordMask|=1<=MAX_FRAME_RECORDS) - return; - DFAIL_IF(!(frameRecordMask&(1<=curFrame) - return; - - ProfileFastCS::Lock lock(cs); - - frameRecordMask^=1<next) - { - Function *f; - for (int k=0;(f=p->func.Enumerate(k))!=NULL;k++) - { - Profile &p=f->cur[which]; - if (p.callCount) - { - if (mixIndex<0) - f->frame.Append(curFrame,p); - else - f->frame.MixIn(mixIndex,p); - } - p.caller.Clear(); - p.callCount=p.tickPure=p.tickTotal=0; - } - } -} - -void ProfileFuncLevelTracer::ClearTotals(void) -{ - ProfileFastCS::Lock lock(cs); - - for (ProfileFuncLevelTracer *p=head;p;p=p->next) - { - Function *f; - for (int k=0;(f=p->func.Enumerate(k))!=NULL;k++) - { - f->glob.caller.Clear(); - f->glob.callCount=0; - f->glob.tickPure=0; - f->glob.tickTotal=0; - } - } -} - -ProfileFuncLevelTracer::UnsignedMap::UnsignedMap(void): - e(NULL), alloc(0), used(0), writeLock(false) -{ - memset(hash,0,sizeof(hash)); -} - -ProfileFuncLevelTracer::UnsignedMap::~UnsignedMap() -{ - Clear(); -} - -void ProfileFuncLevelTracer::UnsignedMap::Clear(void) -{ - ProfileFreeMemory(e); - e=NULL; - alloc=used=0; - memset(hash,0,sizeof(hash)); -} - -void ProfileFuncLevelTracer::UnsignedMap::_Insert(unsigned at, unsigned val, int countAdd) -{ - DFAIL_IF(writeLock) return; - - // realloc list? - if (used==alloc) - { - // must fixup pointers... - unsigned delta=unsigned(e); - e=(Entry *)ProfileReAllocMemory(e,((alloc+=64)*sizeof(Entry))); - delta=unsigned(e)-delta; - if (used&&delta) - { - unsigned k=0; - for (;k=(int)used) - return 0; - return e[index].val; -} - -unsigned ProfileFuncLevelTracer::UnsignedMap::GetCount(int index) -{ - if (index<0||index>=(int)used) - return 0; - return e[index].count; -} - -void ProfileFuncLevelTracer::UnsignedMap::Copy(const UnsignedMap &src) -{ - Clear(); - if (src.e) - { - alloc=used=src.used; - e=(Entry *)ProfileAllocMemory(alloc*sizeof(Entry)); - memcpy(e,src.e,alloc*sizeof(Entry)); - writeLock=true; - } -} - -void ProfileFuncLevelTracer::UnsignedMap::MixIn(const UnsignedMap &src) -{ - writeLock=false; - for (unsigned k=0;knext; - root->~List(); - ProfileFreeMemory(root); - root=next; - } -} - -ProfileFuncLevelTracer::Profile *ProfileFuncLevelTracer::ProfileMap::Find(int frame) -{ - List *p=root; - for (;p&&p->framenext); - return p&&p->frame==frame?&p->p:NULL; -} - -void ProfileFuncLevelTracer::ProfileMap::Append(int frame, const Profile &p) -{ - List *newEntry=(List *)ProfileAllocMemory(sizeof(List)); - new (newEntry) List; - newEntry->frame=frame; - newEntry->p.Copy(p); - newEntry->next=NULL; - *tail=newEntry; - tail=&newEntry->next; -} - -void ProfileFuncLevelTracer::ProfileMap::MixIn(int frame, const Profile &p) -{ - // search correct list entry - List *oldEntry=root; - for (;oldEntry;oldEntry=oldEntry->next) - if (oldEntry->frame==frame) - break; - if (!oldEntry) - Append(frame,p); - else - oldEntry->p.MixIn(p); -} - -ProfileFuncLevelTracer::FunctionMap::FunctionMap(void): - e(NULL), alloc(0), used(0) -{ - memset(hash,0,sizeof(hash)); -} - -ProfileFuncLevelTracer::FunctionMap::~FunctionMap() -{ - if (e) - { - for (unsigned k=0;k~Function(); - ProfileFreeMemory(e[k].funcPtr); - } - ProfileFreeMemory(e); - } -} - -void ProfileFuncLevelTracer::FunctionMap::Insert(Function *funcPtr) -{ - // realloc list? - if (used==alloc) - { - // must fixup pointers... - unsigned delta=unsigned(e); - e=(Entry *)ProfileReAllocMemory(e,(alloc+=1024)*sizeof(Entry)); - delta=unsigned(e)-delta; - if (used&&delta) - { - unsigned k=0; - for (;kaddr/16)%HASH_SIZE; - e[used].funcPtr=funcPtr; - e[used].next=hash[at]; - hash[at]=e+used++; -} - -ProfileFuncLevelTracer::Function *ProfileFuncLevelTracer::FunctionMap::Enumerate(int index) -{ - if (index<0||index>=(int)used) - return NULL; - return e[index].funcPtr; -} - -bool ProfileFuncLevel::IdList::Enum(unsigned index, Id &id, unsigned *countPtr) const -{ - if (!m_ptr) - return false; - - ProfileFuncLevelTracer::Profile &prof=*(ProfileFuncLevelTracer::Profile *)m_ptr; - - unsigned addr = prof.caller.Enumerate(index); - if (addr!=0) - { - id.m_funcPtr=prof.tracer->FindFunction(addr); - if (countPtr) - *countPtr=prof.caller.GetCount(index); - return true; - } - else - return false; -} - -const char *ProfileFuncLevel::Id::GetSource(void) const -{ - if (!m_funcPtr) - return NULL; - - ProfileFuncLevelTracer::Function *func=(ProfileFuncLevelTracer::Function *)m_funcPtr; - if (!func->funcSource) - { - char helpFunc[256],helpFile[256]; - unsigned ofsFunc; - DebugStackwalk::Signature::GetSymbol(func->addr, - NULL,0,NULL, - helpFunc,sizeof(helpFunc),&ofsFunc, - helpFile,sizeof(helpFile),&func->funcLine,NULL); - - char help[300]; - wsprintf(help,ofsFunc?"%s+0x%x":"%s",helpFunc,ofsFunc); - func->funcSource=(char *)ProfileAllocMemory(strlen(helpFile)+1); - strcpy(func->funcSource,helpFile); - func->funcName=(char *)ProfileAllocMemory(strlen(help)+1); - strcpy(func->funcName,help); - } - - return func->funcSource; -} - -const char *ProfileFuncLevel::Id::GetFunction(void) const -{ - if (!m_funcPtr) - return NULL; - ProfileFuncLevelTracer::Function *func=(ProfileFuncLevelTracer::Function *)m_funcPtr; - if (!func->funcSource) - GetSource(); - return func->funcName; -} - -unsigned ProfileFuncLevel::Id::GetAddress(void) const -{ - if (!m_funcPtr) - return 0; - ProfileFuncLevelTracer::Function *func=(ProfileFuncLevelTracer::Function *)m_funcPtr; - return func->addr; -} - -unsigned ProfileFuncLevel::Id::GetLine(void) const -{ - if (!m_funcPtr) - return NULL; - ProfileFuncLevelTracer::Function *func=(ProfileFuncLevelTracer::Function *)m_funcPtr; - if (!func->funcSource) - GetSource(); - return func->funcLine; -} - -unsigned _int64 ProfileFuncLevel::Id::GetCalls(unsigned frame) const -{ - if (!m_funcPtr) - return 0; - - ProfileFuncLevelTracer::Function &func=*(ProfileFuncLevelTracer::Function *)m_funcPtr; - - switch(frame) - { - case Total: - return func.glob.callCount; - default: - ProfileFuncLevelTracer::Profile *prof=func.frame.Find(frame); - return prof?prof->callCount:0; - } -} - -unsigned _int64 ProfileFuncLevel::Id::GetTime(unsigned frame) const -{ - if (!m_funcPtr) - return 0; - - ProfileFuncLevelTracer::Function &func=*(ProfileFuncLevelTracer::Function *)m_funcPtr; - - switch(frame) - { - case Total: - return func.glob.tickTotal; - default: - ProfileFuncLevelTracer::Profile *prof=func.frame.Find(frame); - return prof?prof->tickTotal:0; - } -} - -unsigned _int64 ProfileFuncLevel::Id::GetFunctionTime(unsigned frame) const -{ - if (!m_funcPtr) - return 0; - - ProfileFuncLevelTracer::Function &func=*(ProfileFuncLevelTracer::Function *)m_funcPtr; - - switch(frame) - { - case Total: - return func.glob.tickPure; - default: - ProfileFuncLevelTracer::Profile *prof=func.frame.Find(frame); - return prof?prof->tickPure:0; - } -} - -ProfileFuncLevel::IdList ProfileFuncLevel::Id::GetCaller(unsigned frame) const -{ - if (!m_funcPtr) - return IdList(); - - ProfileFuncLevelTracer::Function &func=*(ProfileFuncLevelTracer::Function *)m_funcPtr; - - IdList ret; - switch(frame) - { - case Total: - ret.m_ptr=&func.glob; - break; - default: - ProfileFuncLevelTracer::Profile *prof=func.frame.Find(frame); - if (prof) - ret.m_ptr=prof; - } - - return ret; -} - -bool ProfileFuncLevel::Thread::EnumProfile(unsigned index, Id &id) const -{ - if (!m_threadID) - return false; - - ProfileFastCS::Lock lock(cs); - - ProfileFuncLevelTracer::Function *f=m_threadID->EnumFunction(index); - if (f) - { - id.m_funcPtr=f; - return true; - } - else - return false; -} - -bool ProfileFuncLevel::EnumThreads(unsigned index, Thread &thread) -{ - ProfileFastCS::Lock lock(cs); - - ProfileFuncLevelTracer *p=ProfileFuncLevelTracer::GetFirst(); - for (;p;p=p->GetNext()) - if (!index--) - break; - if (p) - { - thread.m_threadID=p; - return true; - } - else - return false; -} - -ProfileFuncLevel::ProfileFuncLevel(void) -{ -} - -#else // !defined HAS_PROFILE - -bool ProfileFuncLevel::IdList::Enum(unsigned index, Id &id, unsigned *) const -{ - return false; -} - -const char *ProfileFuncLevel::Id::GetSource(void) const -{ - return NULL; -} - -const char *ProfileFuncLevel::Id::GetFunction(void) const -{ - return NULL; -} - -unsigned ProfileFuncLevel::Id::GetAddress(void) const -{ - return 0; -} - -unsigned ProfileFuncLevel::Id::GetLine(void) const -{ - return 0; -} - -unsigned _int64 ProfileFuncLevel::Id::GetCalls(unsigned frame) const -{ - return 0; -} - -unsigned _int64 ProfileFuncLevel::Id::GetTime(unsigned frame) const -{ - return 0; -} - -unsigned _int64 ProfileFuncLevel::Id::GetFunctionTime(unsigned frame) const -{ - return 0; -} - -ProfileFuncLevel::IdList ProfileFuncLevel::Id::GetCaller(unsigned frame) const -{ - return ProfileFuncLevel::IdList(); -} - -bool ProfileFuncLevel::Thread::EnumProfile(unsigned index, Id &id) const -{ - return false; -} - -bool ProfileFuncLevel::EnumThreads(unsigned index, Thread &thread) -{ - return false; -} - -ProfileFuncLevel::ProfileFuncLevel(void) -{ -} - -#endif // !defined HAS_PROFILE - -ProfileFuncLevel ProfileFuncLevel::Instance; -HANDLE ProfileFastCS::testEvent=::CreateEvent(NULL,FALSE,FALSE,""); diff --git a/Core/Libraries/Source/profile/profile_funclevel.h b/Core/Libraries/Source/profile/profile_funclevel.h deleted file mode 100644 index 8736cf8037..0000000000 --- a/Core/Libraries/Source/profile/profile_funclevel.h +++ /dev/null @@ -1,223 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile_funclevel.h $ -// $Author: mhoffe $ -// $Revision: #3 $ -// $DateTime: 2003/07/09 10:57:23 $ -// -// (c) 2003 Electronic Arts -// -// Function level profiling -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROFILE_FUNCLEVEL_H // Include guard -#define PROFILE_FUNCLEVEL_H - -/** - \brief The function level profiler. - - Note that this class exists even if the current build configuration - is not RTS_PROFILE. In these cases all calls will simply return - empty data. -*/ -class ProfileFuncLevel -{ - friend class Profile; - - // no, no copying allowed! - ProfileFuncLevel(const ProfileFuncLevel&); - ProfileFuncLevel& operator=(const ProfileFuncLevel&); - -public: - class Id; - class Thread; - - /// \brief A list of function level profile IDs - class IdList - { - friend Id; - - public: - IdList(void): m_ptr(0) {} - - /** - \brief Enumerates the list of IDs. - - \note These values are not sorted in any way. - - \param index index value, >=0 - \param id return buffer for ID value - \param countPtr return buffer for count, if given - \return true if ID found at given index, false if not - */ - bool Enum(unsigned index, Id &id, unsigned *countPtr=0) const; - - private: - - /// internal value - void *m_ptr; - }; - - /// \brief A function level profile ID. - class Id - { - friend IdList; - friend Thread; - - public: - Id(void): m_funcPtr(0) {} - - /// special 'frame' numbers - enum - { - /// return the total value/count - Total = 0xffffffff - }; - - /** - \brief Returns the source file this Id is in. - - \return source file name, may be NULL - */ - const char *GetSource(void) const; - - /** - \brief Returns the function name for this Id. - - \return function name, may be NULL - */ - const char *GetFunction(void) const; - - /** - \brief Returns function address. - - \return function address - */ - unsigned GetAddress(void) const; - - /** - \brief Returns the line number for this Id. - - \return line number, 0 if unknown - */ - unsigned GetLine(void) const; - - /** - \brief Determine call counts. - - \param frame number of recorded frame, or Total - \return number of calls - */ - unsigned _int64 GetCalls(unsigned frame) const; - - /** - \brief Determine time spend in this function and its children. - - \param frame number of recorded frame, or Total - \return time spend (in CPU ticks) - */ - unsigned _int64 GetTime(unsigned frame) const; - - /** - \brief Determine time spend in this function only (exclude - any time spend in child functions). - - \param frame number of recorded frame, or Total - \return time spend in this function alone (in CPU ticks) - */ - unsigned _int64 GetFunctionTime(unsigned frame) const; - - /** - \brief Determine the list of caller Ids. - - \param frame number of recorded frame, or Total - \return Caller Id list (actually just a handle value) - */ - IdList GetCaller(unsigned frame) const; - - private: - /// internal function pointer - void *m_funcPtr; - }; - - /// \brief a profiled thread - class Thread - { - friend ProfileFuncLevel; - - public: - Thread(void): m_threadID(0) {} - - /** - \brief Enumerates the list of known function level profile values. - - \note These values are not sorted in any way. - - \param index index value, >=0 - \param id return buffer for ID value - \return true if ID found at given index, false if not - */ - bool EnumProfile(unsigned index, Id &id) const; - - /** - \brief Returns a unique thread ID (not related to Windows thread ID) - - \return profile thread ID - */ - unsigned GetId(void) const - { - return unsigned(m_threadID); - } - - private: - /// internal thread ID - class ProfileFuncLevelTracer *m_threadID; - }; - - /** - \brief Enumerates the list of known and profiled threads. - - \note These values are not sorted in any way. - - \param index index value, >=0 - \param thread return buffer for thread handle - \return true if Thread found, false if not - */ - static bool EnumThreads(unsigned index, Thread &thread); - -private: - - /** \internal - - Undocumented default constructor. Initializes function level profiler. - We can make this private as well so nobody accidently tries to create - another instance. - */ - ProfileFuncLevel(void); - - /** - \brief The only function level profiler instance. - */ - static ProfileFuncLevel Instance; -}; - -#endif // PROFILE_FUNCLEVEL_H diff --git a/Core/Libraries/Source/profile/profile_highlevel.cpp b/Core/Libraries/Source/profile/profile_highlevel.cpp deleted file mode 100644 index bdd840e384..0000000000 --- a/Core/Libraries/Source/profile/profile_highlevel.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile_highlevel.cpp $ -// $Author: mhoffe $ -// $Revision: #2 $ -// $DateTime: 2003/08/14 13:43:29 $ -// -// (c) 2003 Electronic Arts -// -// High level profiling -////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" -#include -#include - -// our own fast critical section -static ProfileFastCS cs; - -////////////////////////////////////////////////////////////////////////////// -// ProfileHighLevel::Id - -void ProfileHighLevel::Id::Increment(double add) -{ - if (m_idPtr) - m_idPtr->Increment(add); -} - -void ProfileHighLevel::Id::SetMax(double max) -{ - if (m_idPtr) - m_idPtr->Maximum(max); -} - -const char *ProfileHighLevel::Id::GetName(void) const -{ - return m_idPtr?m_idPtr->GetName():NULL; -} - -const char *ProfileHighLevel::Id::GetDescr(void) const -{ - return m_idPtr?m_idPtr->GetDescr():NULL; -} - -const char *ProfileHighLevel::Id::GetUnit(void) const -{ - return m_idPtr?m_idPtr->GetUnit():NULL; -} - -const char *ProfileHighLevel::Id::GetCurrentValue(void) const -{ - return m_idPtr?m_idPtr->AsString(m_idPtr->GetCurrentValue()):NULL; -} - -const char *ProfileHighLevel::Id::GetValue(unsigned frame) const -{ - double v; - if (!m_idPtr||!m_idPtr->GetFrameValue(frame,v)) - return NULL; - return m_idPtr->AsString(v); -} - -const char *ProfileHighLevel::Id::GetTotalValue(void) const -{ - return m_idPtr?m_idPtr->AsString(m_idPtr->GetTotalValue()):NULL; -} - -////////////////////////////////////////////////////////////////////////////// -// ProfileHighLevel::Block - -ProfileHighLevel::Block::Block(const char *name) -{ - DFAIL_IF(!name) return; - - m_idTime=AddProfile(name,NULL,"msec",6,-4); - - char help[256]; - strncpy(help,name,sizeof(help)); - help[sizeof(help)-1-2]=0; - strcat(help,".c"); - AddProfile(help,NULL,"calls",6,0).Increment(); - - ProfileGetTime(m_start); -} - -ProfileHighLevel::Block::~Block() -{ - _int64 end; - ProfileGetTime(end); - end-=m_start; - - m_idTime.Increment(double(end)/(double)Profile::GetClockCyclesPerSecond()); -} - -////////////////////////////////////////////////////////////////////////////// -// ProfileId - -// profile ID stuff -ProfileId *ProfileId::first; -int ProfileId::curFrame; -unsigned ProfileId::frameRecordMask; -char ProfileId::stringBuf[ProfileId::STRING_BUFFER_SIZE]; -unsigned ProfileId::stringBufUnused; - -ProfileId::ProfileId(const char *name, const char *descr, const char *unit, int precision, int exp10) -{ - m_next=first; first=this; - m_name=(char *)ProfileAllocMemory(strlen(name)+1); - strcpy(m_name,name); - if (descr) - { - m_descr=(char *)ProfileAllocMemory(strlen(descr)+1); - strcpy(m_descr,descr); - } - else - m_descr=NULL; - if (unit) - { - m_unit=(char *)ProfileAllocMemory(strlen(unit)+1); - strcpy(m_unit,unit); - } - else - m_unit=NULL; - m_precision=precision; - m_exp10=exp10; - m_curVal=m_totalVal=0.; - m_recFrameVal=NULL; - m_firstFrame=curFrame; - m_valueMode=Unknown; -} - -void ProfileId::Increment(double add) -{ - DFAIL_IF(m_valueMode!=Unknown&&m_valueMode!=ModeIncrement) - return; - - m_valueMode=ModeIncrement; - m_curVal+=add; - m_totalVal+=add; - if (frameRecordMask) - { - unsigned mask=frameRecordMask; - for (unsigned i=0;i>=1)) - break; - } - } -} - -void ProfileId::Maximum(double max) -{ - DFAIL_IF(m_valueMode!=Unknown&&m_valueMode!=ModeMaximum) - return; - - m_valueMode=ModeMaximum; - if (max>m_curVal) - m_curVal=max; - if (max>m_totalVal) - m_totalVal=max; - if (frameRecordMask) - { - unsigned mask=frameRecordMask; - for (unsigned i=0;im_frameVal[i]) - m_frameVal[i]=max; - } - if (!(mask>>=1)) - break; - } - } -} - -const char *ProfileId::AsString(double v) const -{ - char help1[10],help[40]; - wsprintf(help1,"%%%i.lf",m_precision); - - double mul=1.0; - int k; - for (k=m_exp10;k<0;k++) mul*=10.0; - for (;k>0;k--) mul/=10.0; - - unsigned len=snprintf(help,sizeof(help),help1,v*mul)+1; - - ProfileFastCS::Lock lock(cs); - if (stringBufUnused+len>STRING_BUFFER_SIZE) - stringBufUnused=0; - char *ret=stringBuf+stringBufUnused; - memcpy(ret,help,len); - stringBufUnused+=len; - return ret; -} - -int ProfileId::FrameStart(void) -{ - ProfileFastCS::Lock lock(cs); - - unsigned i=0; - for (;im_next) - p->m_frameVal[i]=0.; - - frameRecordMask|=1<=MAX_FRAME_RECORDS) - return; - DFAIL_IF(!(frameRecordMask&(1<=curFrame) - return; - - ProfileFastCS::Lock lock(cs); - - frameRecordMask^=1<m_next) - { - p->m_recFrameVal=(double *)ProfileReAllocMemory(p->m_recFrameVal,sizeof(double)*(curFrame-p->m_firstFrame)); - p->m_recFrameVal[curFrame-p->m_firstFrame-1]=p->m_frameVal[which]; - } - } - else - { - // append data - for (ProfileId *p=first;p;p=p->m_next) - { - if (p->m_firstFrame>mixIndex) - continue; - - double &val=p->m_recFrameVal[mixIndex-p->m_firstFrame]; - switch(p->m_valueMode) - { - case ProfileId::Unknown: - break; - case ProfileId::ModeIncrement: - val+=p->m_frameVal[which]; - break; - case ProfileId::ModeMaximum: - if (p->m_frameVal[which]>val) - val=p->m_frameVal[which]; - break; - default: - DFAIL(); - } - } - } -} - -void ProfileId::Shutdown(void) -{ - if (frameRecordMask) - { - for (unsigned i=0;iGetNext()); - id.m_idPtr=cur; - return cur!=NULL; -} - -bool ProfileHighLevel::FindProfile(const char *name, Id &id) -{ - DFAIL_IF(!name) return false; - - ProfileFastCS::Lock lock(cs); - for (ProfileId *cur=ProfileId::GetFirst();cur;cur=cur->GetNext()) - if (!strcmp(name,cur->GetName())) - { - id.m_idPtr=cur; - return true; - } - - id.m_idPtr=NULL; - return false; -} - -ProfileHighLevel::ProfileHighLevel(void) -{ -} - -ProfileHighLevel ProfileHighLevel::Instance; diff --git a/Core/Libraries/Source/profile/profile_highlevel.h b/Core/Libraries/Source/profile/profile_highlevel.h deleted file mode 100644 index 26e6da1c30..0000000000 --- a/Core/Libraries/Source/profile/profile_highlevel.h +++ /dev/null @@ -1,241 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile_highlevel.h $ -// $Author: mhoffe $ -// $Revision: #2 $ -// $DateTime: 2003/07/09 10:57:23 $ -// -// (c) 2003 Electronic Arts -// -// High level profiling -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROFILE_HIGHLEVEL_H // Include guard -#define PROFILE_HIGHLEVEL_H - -/// \internal internal Id representation -class ProfileId; - -/** - \brief The high level profiler. -*/ -class ProfileHighLevel -{ - friend class Profile; - - // no, no copying allowed! - ProfileHighLevel(const ProfileHighLevel&); - ProfileHighLevel& operator=(const ProfileHighLevel&); - -public: - - /// \brief A high level profile ID. - class Id - { - friend ProfileHighLevel; - - public: - Id(void): m_idPtr(0) {} - - /** - \brief Increment the internal profile value. - - \note Do not mix with SetMax. - - \param add amount to add to internal profile value - */ - void Increment(double add=1.0); - - /** - \brief Set a new maximum value. - - \note Do not mix with Increment. - - This function sets a new maximum value (if the value - passed in is actually larger than the current max value). - - \param max new maximum value (if larger than current max value, - otherwise current max value is left unchanged) - */ - void SetMax(double max); - - /** - \brief Returns the internal Id name. - - \return internal Id name, e.g. 'render.texture.count.512x512' - */ - const char *GetName(void) const; - - /** - \brief Returns the descriptive name. - - \return descriptive name, e.g. '# of 512x512 textures' - */ - const char *GetDescr(void) const; - - /** - \brief Returns the value's unit text. - - \return unit text, e.g. 'bytes' - */ - const char *GetUnit(void) const; - - /** - \brief Returns the current value. - - 'Current' means the value since the last call to this function for - the same Id. - - This function is intended for displaying profile data while the - application is running. - - \note The contents of the buffer returned may be overwritten by - any consecutive call to any profile module function. - - \return current value - */ - const char *GetCurrentValue(void) const; - - /** - \brief Returns the value for the given recorded frame/range. - - \note The contents of the buffer returned may be overwritten by - any consecutive call to any profile module function. - - \param frame number of recorded frame/range - \return value at given frame, NULL if frame not found - */ - const char *GetValue(unsigned frame) const; - - /** - \brief Returns the total value for all frames. - - This even includes data collected while no frames have been - recorded. - - \note A call to ProfileHighLevel::ClearTotals() resets this value. - - \return total value - */ - const char *GetTotalValue(void) const; - - private: - - /// internal pointer - ProfileId *m_idPtr; - }; - - /// \brief Timer based function block profile - class Block - { - friend ProfileHighLevel; - - // no copying - Block(const Block&); - Block& operator=(const Block&); - - public: - /** - \brief Instructs high level profiler to start a new timer - based function block (or update if it already exists) - - \note These function blocks are in the same name space as - high level profile values registered with ProfileHighLevel::AddProfile() - - \param name name of function block - */ - explicit Block(const char *name); - - /// \brief Updates timer based function block - ~Block(); - - private: - /// internal id (time) - Id m_idTime; - - /// start time - _int64 m_start; - }; - - /** - \brief Registers a new high level profile value. - - If there is already a high level profile with the given name the - Id of that profile is returned instead. - - High level profiles can only be added, never removed. - - \note Important: This function can (and should) be used in static - initializers! - - \note This function may be slow so don't use it too often. - - \param name value name, e.g. "render.texture.count.512x512" - \param descr descriptive name, e.g. "# of 512x512 textures" - \param unit unit name, e.g. "byte" or "sec" - \param precision number of decimal places to show - \param exp10 10 base exponent (used for scaleing) - \return internal profile ID value - */ - static Id AddProfile(const char *name, const char *descr, const char *unit, int precision, int exp10=0); - - /** - \brief Enumerates the list of known high level profile values. - - \note Profiles are always sorted ascending by profile name. - - \param index index value, >=0 - \param id return buffer for ID value - \return true if ID found at given index, false if not - */ - static bool EnumProfile(unsigned index, Id &id); - - /** - \brief Searches for the given high level profile. - - \note Actually the ID returned belongs to the first profile - which has a name that is equal to or larger than the name - searched for. - - \param name profile name to search for - \param id return buffer for ID value - \return true if ID found, false if not - */ - static bool FindProfile(const char *name, Id &id); - -private: - - /** \internal - - Undocumented default constructor. Initializes high level profiler. - We can make this private as well so nobody accidently tries to create - another instance. - */ - ProfileHighLevel(void); - - /** - \brief The only high level profiler instance. - */ - static ProfileHighLevel Instance; -}; - -#endif // PROFILE_HIGHLEVEL_H diff --git a/Core/Libraries/Source/profile/profile_priv.dox b/Core/Libraries/Source/profile/profile_priv.dox deleted file mode 100644 index ab3f256207..0000000000 --- a/Core/Libraries/Source/profile/profile_priv.dox +++ /dev/null @@ -1,208 +0,0 @@ -# Doxyfile 1.3.1 - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = "EA/Profile module" -PROJECT_NUMBER = -OUTPUT_DIRECTORY = doc/ -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = YES -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -HIDE_UNDOC_MEMBERS = YES -HIDE_UNDOC_CLASSES = YES -HIDE_FRIEND_COMPOUNDS = YES -HIDE_IN_BODY_DOCS = YES -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = YES -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -INTERNAL_DOCS = YES -CASE_SENSE_NAMES = YES -SHORT_NAMES = NO -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ALIASES = "todo_opt=\todo (Opt) " \ - "todo_urgent=\todo (URGENT) " \ - "todo_feature=\todo (Feature) " -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -SHOW_USED_FILES = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = ./ -FILE_PATTERNS = profile*.h internal*.h *.cpp -RECURSIVE = NO -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -VERBATIM_HEADERS = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html_priv -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = YES -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = YES -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = YES -RTF_OUTPUT = rtf_priv -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = RTS_DEBUG \ - DOXYGEN -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -DOT_IMAGE_FORMAT = png -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 0 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO -CGI_NAME = search.cgi -CGI_URL = -DOC_URL = -DOC_ABSPATH = -BIN_ABSPATH = /usr/local/bin/ -EXT_DOC_PATHS = diff --git a/Core/Libraries/Source/profile/profile_result.cpp b/Core/Libraries/Source/profile/profile_result.cpp deleted file mode 100644 index 2cc08ba936..0000000000 --- a/Core/Libraries/Source/profile/profile_result.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile_result.cpp $ -// $Author: mhoffe $ -// $Revision: #2 $ -// $DateTime: 2003/08/12 15:05:00 $ -// -// (c) 2003 Electronic Arts -// -// Result function interface and result functions -////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" -#include -#include -#include - -////////////////////////////////////////////////////////////////////////////// -// ProfileResultFileCSV - -ProfileResultInterface *ProfileResultFileCSV::Create(int, const char * const *) -{ - return new (ProfileAllocMemory(sizeof(ProfileResultFileCSV))) ProfileResultFileCSV(); -} - -void ProfileResultFileCSV::WriteThread(ProfileFuncLevel::Thread &thread) -{ - char help[40]; - - sprintf(help,"prof%08x-all.csv",thread.GetId()); - FILE *f=fopen(help,"wt"); - - // CSV file header - fprintf(f,"Function\tFile\tCall count\tPTT (all)\tGTT (all)\tPT/C (all)\tGT/C (all)\tCaller (all)"); - unsigned k=0; - for (;k~ProfileResultFileCSV(); - ProfileFreeMemory(this); -} - -////////////////////////////////////////////////////////////////////////////// -// ProfileResultFileDOT - -ProfileResultInterface *ProfileResultFileDOT::Create(int argn, const char * const *argv) -{ - return new (ProfileAllocMemory(sizeof(ProfileResultFileDOT))) - ProfileResultFileDOT(argn>0?argv[0]:NULL, - argn>1?argv[1]:NULL, - argn>2?atoi(argv[2]):NULL); -} - -ProfileResultFileDOT::ProfileResultFileDOT(const char *fileName, const char *frameName, int foldThreshold) -{ - if (!fileName) - fileName="profile.dot"; - m_fileName=(char *)ProfileAllocMemory(strlen(fileName)+1); - strcpy(m_fileName,fileName); - if (frameName) - { - m_frameName=(char *)ProfileAllocMemory(strlen(frameName)+1); - strcpy(m_frameName,frameName); - } - else - m_frameName=NULL; - m_foldThreshold=foldThreshold; -} - -void ProfileResultFileDOT::WriteResults(void) -{ - // search "main" thread - ProfileFuncLevel::Thread t,tMax; - if (!ProfileFuncLevel::EnumThreads(0,tMax)) - return; - - unsigned curMax=0; - unsigned k=1; - for (;ProfileFuncLevel::EnumThreads(k,t);k++) - { - for (;curMax++;) - { - ProfileFuncLevel::Id help; - if (!tMax.EnumProfile(curMax,help)) - { - tMax=t; - break; - } - if (!t.EnumProfile(curMax,help)) - break; - curMax++; - } - } - - // search frame - unsigned frame=ProfileFuncLevel::Id::Total; - if (m_frameName) - { - for (unsigned k=0;km_foldThreshold?"closed":"none"); - - // fold or not? - if (active>m_foldThreshold) - { - // folding version - - // build source code clusters first - FoldHelper *fold=NULL; - for (k=0;tMax.EnumProfile(k,id);k++) - { - const char *source=id.GetSource(); - FoldHelper *cur=fold; - for (;cur;cur=cur->next) - if (!strcmp(source,cur->source)) - { - if (cur->numIdid[cur->numId++]=id; - break; - } - if (!cur) - { - cur=(FoldHelper *)ProfileAllocMemory(sizeof(FoldHelper)); - cur->next=fold; - fold=cur; - cur->source=source; - cur->numId=1; - cur->id[0]=id; - } - } - - // now write data - for (FoldHelper *cur=fold;cur;cur=cur->next) - { - FoldHelper *cur2=fold; - for (;cur2;cur2=cur2->next) - cur2->mark=false; - - for (k=0;knumId;k++) - { - ProfileFuncLevel::IdList idlist=id.GetCaller(frame); - ProfileFuncLevel::Id caller; - for (unsigned i=0;idlist.Enum(i,caller);i++) - { - const char *s=caller.GetSource(); - for (FoldHelper *cur2=fold;cur2;cur2=cur2->next) - if (!strcmp(cur2->source,s)) - break; - if (!cur2||cur2->mark) - continue; - cur2->mark=true; - - fprintf(f,"\"%s\" -> \"%s\"\n",s,cur->source); - } - } - } - - // cleanup - while (fold) - { - FoldHelper *next=fold->next; - ProfileFreeMemory(fold); - fold=next; - } - } - else - { - // non-folding version - for (k=0;tMax.EnumProfile(k,id);k++) - if (id.GetCalls(frame)) - fprintf(f,"f%08x [label=\"%s\"]\n",id.GetAddress(),id.GetFunction()); - for (k=0;tMax.EnumProfile(k,id);k++) - { - ProfileFuncLevel::IdList idlist=id.GetCaller(frame); - ProfileFuncLevel::Id caller; - unsigned count; - for (unsigned i=0;idlist.Enum(i,caller,&count);i++) - fprintf(f,"f%08x -> f%08x [headlabel=\"%i\"];\n",caller.GetAddress(),id.GetAddress(),count); - } - } - - fprintf(f,"}\n"); - fclose(f); -} - -void ProfileResultFileDOT::Delete(void) -{ - this->~ProfileResultFileDOT(); - ProfileFreeMemory(this); -} diff --git a/Core/Libraries/Source/profile/profile_result.h b/Core/Libraries/Source/profile/profile_result.h deleted file mode 100644 index afa920bfe6..0000000000 --- a/Core/Libraries/Source/profile/profile_result.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile_result.h $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/09 10:57:23 $ -// -// (c) 2003 Electronic Arts -// -// Result function interface and result functions -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROFILE_RESULT_H // Include guard -#define PROFILE_RESULT_H - -/** - \brief Result function class. - - Factories for instances of this class are registered using - \ref Profile::AddResultFunction. -*/ -class ProfileResultInterface -{ - // no copying - ProfileResultInterface(const ProfileResultInterface&); - ProfileResultInterface& operator=(const ProfileResultInterface&); - -public: - /** - \brief Write out results. - - This function is called on program exit. - */ - virtual void WriteResults(void)=0; - - /** - \brief Destroys the current result function. - - Use this function instead of just delete'ing the instance. - */ - virtual void Delete(void)=0; - -protected: - ProfileResultInterface(void) {} -}; - -#endif // PROFILE_RESULT_H diff --git a/Core/Libraries/Source/profile/test1/test1.cpp b/Core/Libraries/Source/profile/test1/test1.cpp deleted file mode 100644 index 7a5fc24750..0000000000 --- a/Core/Libraries/Source/profile/test1/test1.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/test1/test1.cpp $ -// $Author: mhoffe $ -// $Revision: #3 $ -// $DateTime: 2003/07/09 10:57:23 $ -// -// (c) 2003 Electronic Arts -// -// Profile module - Test 1 (basic testing) -////////////////////////////////////////////////////////////////////////////// -#include "../profile.h" -#include "../../debug/debug.h" -#include - -const char *DebugGetDefaultCommands(void) -{ - return "!debug.io con add\ndebug.add l + *\nprofile.result"; -} - -extern int q; - -void calcThis(void) -{ - q++; -} - -void calcThat(void) -{ - calcThis(); - q--; -} - -// it must be done this "complicated" because -// otherwise VC does not generate a real recursive -// function call for this simple function... -void recursion2(int level); - -void recursion(int level) -{ - q+=level; - if (level<5000) - recursion2(level+1); -} - -void recursion2(int level) -{ - recursion(level); -} - -void recursionShell(void) -{ - ProfileHighLevel::Block b("Test block"); - recursion(0); -} - -void showResults(void) -{ - ProfileHighLevel::Id id; - for (unsigned index=0;ProfileHighLevel::EnumProfile(index,id);index++) - printf("%-16s%-6s %s\n",id.GetName(),id.GetTotalValue(),id.GetUnit()); -} - -void main(void) -{ - for (int k=0;k<100;k++) - if (k%2&&k>80) - calcThat(); - else - calcThis(); - - recursionShell(); - - showResults(); -} - -int q; diff --git a/Core/Tools/ImagePacker/CMakeLists.txt b/Core/Tools/ImagePacker/CMakeLists.txt index 3b30d71bb9..26f2f731ab 100644 --- a/Core/Tools/ImagePacker/CMakeLists.txt +++ b/Core/Tools/ImagePacker/CMakeLists.txt @@ -29,7 +29,6 @@ target_link_libraries(corei_imagepacker INTERFACE benchmark comctl32 core_debug - core_profile dbghelplib imm32 vfw32 diff --git a/Core/Tools/MapCacheBuilder/CMakeLists.txt b/Core/Tools/MapCacheBuilder/CMakeLists.txt index 5d390853a8..78d273d56a 100644 --- a/Core/Tools/MapCacheBuilder/CMakeLists.txt +++ b/Core/Tools/MapCacheBuilder/CMakeLists.txt @@ -16,7 +16,6 @@ target_include_directories(corei_mapcachebuilder INTERFACE target_link_libraries(corei_mapcachebuilder INTERFACE comctl32 core_debug - core_profile dbghelplib imm32 vfw32 diff --git a/Core/Tools/PATCHGET/CMakeLists.txt b/Core/Tools/PATCHGET/CMakeLists.txt index 265a74c785..7928445e2c 100644 --- a/Core/Tools/PATCHGET/CMakeLists.txt +++ b/Core/Tools/PATCHGET/CMakeLists.txt @@ -24,7 +24,6 @@ target_sources(corei_patchgrabber INTERFACE ${PATCHGET_SRC}) target_link_libraries(corei_patchgrabber INTERFACE comctl32 core_debug - core_profile dbghelplib gamespy::gamespy imm32 diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp index f507410f4d..435cdd01c8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp @@ -101,7 +101,7 @@ enum static Bool raiseMessageBoxes = TRUE; static Bool campaignSelected = FALSE; -#if defined RTS_DEBUG || defined RTS_INTERNAL || defined RTS_PROFILE +#if defined RTS_DEBUG || defined RTS_INTERNAL static NameKeyType campaignID = NAMEKEY_INVALID; static GameWindow *buttonCampaign = NULL; #ifdef TEST_COMPRESSION @@ -554,7 +554,7 @@ void MainMenuInit( WindowLayout *layout, void *userData ) showSelectiveButtons(SHOW_NONE); // Set up the version number -#if defined RTS_DEBUG || defined RTS_INTERNAL || defined RTS_PROFILE +#if defined RTS_DEBUG || defined RTS_INTERNAL WinInstanceData instData; #ifdef TEST_COMPRESSION instData.init(); @@ -1309,7 +1309,7 @@ WindowMsgHandledType MainMenuSystem( GameWindow *window, UnsignedInt msg, if(buttonPushed) break; -#if defined RTS_DEBUG || defined RTS_INTERNAL || defined RTS_PROFILE +#if defined RTS_DEBUG || defined RTS_INTERNAL if( control == buttonCampaign ) { buttonPushed = TRUE; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp index ea50ed4e8f..88809c0216 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp @@ -42,8 +42,6 @@ #include "GameNetwork/GameSpyOverlay.h" #include "GameNetwork/GameSpy/PeerDefsImplementation.h" -#include - // PUBLIC DATA //////////////////////////////////////////////////////////////////////////////////// Shell *TheShell = NULL; ///< the shell singleton definition @@ -460,9 +458,6 @@ void Shell::showShell( Bool runInit ) if (!TheGlobalData->m_shellMapOn && m_screenCount == 0) { -#ifdef RTS_PROFILE - Profile::StopRange("init"); -#endif //else TheShell->push( AsciiString("Menus/MainMenu.wnd") ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index dfc1909655..aa0459daa8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -109,8 +109,6 @@ #include "GameNetwork/NetworkInterface.h" #include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include - DECLARE_PERF_TIMER(SleepyMaintenance) #include "Common/UnitTimings.h" //Contains the DO_UNIT_TIMINGS define jba. @@ -3634,14 +3632,7 @@ void GameLogic::update( void ) Total_Create_Render_Obj_Time=0; Total_Load_3D_Assets=0; #endif - -#ifdef RTS_PROFILE - Profile::StartRange("map_load"); -#endif startNewGame( FALSE ); -#ifdef RTS_PROFILE - Profile::StopRange("map_load"); -#endif m_startNewGame = FALSE; #ifdef DUMP_PERF_STATS diff --git a/GeneralsMD/Code/Main/CMakeLists.txt b/GeneralsMD/Code/Main/CMakeLists.txt index 2ef80b3e87..6feb78dab2 100644 --- a/GeneralsMD/Code/Main/CMakeLists.txt +++ b/GeneralsMD/Code/Main/CMakeLists.txt @@ -11,7 +11,6 @@ target_link_libraries(z_generals PRIVATE binkstub comctl32 core_debug - core_profile d3d8 d3dx8 dbghelplib diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cpp index 95196922a8..4835588fd7 100644 --- a/GeneralsMD/Code/Main/WinMain.cpp +++ b/GeneralsMD/Code/Main/WinMain.cpp @@ -66,8 +66,6 @@ #include "GeneratedVersion.h" #include "resource.h" -#include - #ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) @@ -763,10 +761,6 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, Int nCmdShow ) { -#ifdef RTS_PROFILE - Profile::StartRange("init"); -#endif - try { _set_se_translator( DumpExceptionInfo ); // Hook that allows stack trace. @@ -816,7 +810,7 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, // Force "splash image" to be loaded from a file, not a resource so same exe can be used in different localizations. -#if defined RTS_DEBUG || defined RTS_INTERNAL || defined RTS_PROFILE +#if defined RTS_DEBUG || defined RTS_INTERNAL // check both localized directory and root dir char filePath[_MAX_PATH]; diff --git a/GeneralsMD/Code/Tools/GUIEdit/CMakeLists.txt b/GeneralsMD/Code/Tools/GUIEdit/CMakeLists.txt index e401d8d335..66ae84647b 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/CMakeLists.txt +++ b/GeneralsMD/Code/Tools/GUIEdit/CMakeLists.txt @@ -49,7 +49,6 @@ target_link_libraries(z_guiedit PRIVATE benchmark comctl32 core_debug - core_profile d3d8lib dbghelplib imm32 diff --git a/GeneralsMD/Code/Tools/ParticleEditor/CMakeLists.txt b/GeneralsMD/Code/Tools/ParticleEditor/CMakeLists.txt index 0b410f3470..245bc47133 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/CMakeLists.txt +++ b/GeneralsMD/Code/Tools/ParticleEditor/CMakeLists.txt @@ -38,7 +38,6 @@ target_include_directories(z_particleeditor PRIVATE target_link_libraries(z_particleeditor PRIVATE core_debug - core_profile corei_libraries_source_wwvegas corei_libraries_source_wwvegas_wwlib d3d8lib diff --git a/GeneralsMD/Code/Tools/WorldBuilder/CMakeLists.txt b/GeneralsMD/Code/Tools/WorldBuilder/CMakeLists.txt index c24f97e585..736bc9fac7 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/CMakeLists.txt +++ b/GeneralsMD/Code/Tools/WorldBuilder/CMakeLists.txt @@ -211,7 +211,6 @@ target_include_directories(z_worldbuilder PRIVATE target_link_libraries(z_worldbuilder PRIVATE core_debug - core_profile d3d8lib dbghelplib imm32 diff --git a/cmake/config-build.cmake b/cmake/config-build.cmake index a001e42c59..816b406973 100644 --- a/cmake/config-build.cmake +++ b/cmake/config-build.cmake @@ -4,7 +4,6 @@ option(RTS_BUILD_CORE_EXTRAS "Build core extra tools/tests" OFF) option(RTS_BUILD_ZEROHOUR "Build Zero Hour code." ON) option(RTS_BUILD_GENERALS "Build Generals code." ON) option(RTS_BUILD_OPTION_INTERNAL "Build code with the \"Internal\" configuration." OFF) -option(RTS_BUILD_OPTION_PROFILE "Build code with the \"Profile\" configuration." OFF) option(RTS_BUILD_OPTION_DEBUG "Build code with the \"Debug\" configuration." OFF) option(RTS_BUILD_OPTION_ASAN "Build code with Address Sanitizer." OFF) option(RTS_BUILD_OPTION_FFMPEG "Enable FFmpeg support" OFF) @@ -19,7 +18,6 @@ add_feature_info(CoreExtras RTS_BUILD_CORE_EXTRAS "Build Core Extra Tools/Tests" add_feature_info(ZeroHourStuff RTS_BUILD_ZEROHOUR "Build Zero Hour code") add_feature_info(GeneralsStuff RTS_BUILD_GENERALS "Build Generals code") add_feature_info(InternalBuild RTS_BUILD_OPTION_INTERNAL "Building as an \"Internal\" build") -add_feature_info(ProfileBuild RTS_BUILD_OPTION_PROFILE "Building as a \"Profile\" build") add_feature_info(DebugBuild RTS_BUILD_OPTION_DEBUG "Building as a \"Debug\" build") add_feature_info(AddressSanitizer RTS_BUILD_OPTION_ASAN "Building with address sanitizer") add_feature_info(FFmpegSupport RTS_BUILD_OPTION_FFMPEG "Building with FFmpeg support") @@ -68,7 +66,4 @@ else() if(RTS_BUILD_OPTION_INTERNAL) target_compile_definitions(core_config INTERFACE RTS_INTERNAL) endif() - if(RTS_BUILD_OPTION_PROFILE) - target_compile_definitions(core_config INTERFACE RTS_PROFILE) - endif() endif()