Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
profile_funclevel.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
20// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/profile_funclevel.h $
21// $Author: mhoffe $
22// $Revision: #3 $
23// $DateTime: 2003/07/09 10:57:23 $
24//
25// ©2003 Electronic Arts
26//
27// Function level profiling
29#ifdef _MSC_VER
30# pragma once
31#endif
32#ifndef PROFILE_FUNCLEVEL_H // Include guard
33#define PROFILE_FUNCLEVEL_H
34
42class ProfileFuncLevel
43{
44 friend class Profile;
45
46 // no, no copying allowed!
47 ProfileFuncLevel(const ProfileFuncLevel&);
48 ProfileFuncLevel& operator=(const ProfileFuncLevel&);
49
50public:
51 class Id;
52 class Thread;
53
55 class IdList
56 {
57 friend Id;
58
59 public:
60 IdList(void): m_ptr(0) {}
61
72 bool Enum(unsigned index, Id &id, unsigned *countPtr=0) const;
73
74 private:
75
77 void *m_ptr;
78 };
79
81 class Id
82 {
83 friend IdList;
84 friend Thread;
85
86 public:
87 Id(void): m_funcPtr(0) {}
88
90 enum
91 {
93 Total = 0xffffffff
94 };
95
101 const char *GetSource(void) const;
102
108 const char *GetFunction(void) const;
109
115 unsigned GetAddress(void) const;
116
122 unsigned GetLine(void) const;
123
130 unsigned _int64 GetCalls(unsigned frame) const;
131
138 unsigned _int64 GetTime(unsigned frame) const;
139
147 unsigned _int64 GetFunctionTime(unsigned frame) const;
148
155 IdList GetCaller(unsigned frame) const;
156
157 private:
159 void *m_funcPtr;
160 };
161
163 class Thread
164 {
165 friend ProfileFuncLevel;
166
167 public:
168 Thread(void): m_threadID(0) {}
169
179 bool EnumProfile(unsigned index, Id &id) const;
180
186 unsigned GetId(void) const
187 {
188 return unsigned(m_threadID);
189 }
190
191 private:
193 class ProfileFuncLevelTracer *m_threadID;
194 };
195
205 static bool EnumThreads(unsigned index, Thread &thread);
206
207private:
208
215 ProfileFuncLevel(void);
216
220 static ProfileFuncLevel Instance;
221};
222
223#endif // PROFILE_FUNCLEVEL_H
A function level profile ID.
unsigned GetAddress(void) const
Returns function address.
unsigned _int64 GetFunctionTime(unsigned frame) const
Determine time spend in this function only (exclude any time spend in child functions).
unsigned _int64 GetCalls(unsigned frame) const
Determine call counts.
@ Total
return the total value/count
unsigned GetLine(void) const
Returns the line number for this Id.
unsigned _int64 GetTime(unsigned frame) const
Determine time spend in this function and its children.
const char * GetSource(void) const
Returns the source file this Id is in.
const char * GetFunction(void) const
Returns the function name for this Id.
IdList GetCaller(unsigned frame) const
Determine the list of caller Ids.
A list of function level profile IDs.
bool Enum(unsigned index, Id &id, unsigned *countPtr=0) const
Enumerates the list of IDs.
unsigned GetId(void) const
Returns a unique thread ID (not related to Windows thread ID)
bool EnumProfile(unsigned index, Id &id) const
Enumerates the list of known function level profile values.
The function level profiler.
static bool EnumThreads(unsigned index, Thread &thread)
Enumerates the list of known and profiled threads.