Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
test1.cpp
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/test1/test1.cpp $
21// $Author: mhoffe $
22// $Revision: #3 $
23// $DateTime: 2003/07/09 10:57:23 $
24//
25// ©2003 Electronic Arts
26//
27// Profile module - Test 1 (basic testing)
29#include "../profile.h"
30#include "../../debug/debug.h"
31#include <stdio.h>
32
33const char *DebugGetDefaultCommands(void)
34{
35 return "!debug.io con add\ndebug.add l + *\nprofile.result";
36}
37
38extern int q;
39
40void calcThis(void)
41{
42 q++;
43}
44
45void calcThat(void)
46{
47 calcThis();
48 q--;
49}
50
51// it must be done this "complicated" because
52// otherwise VC does not generate a real recursive
53// function call for this simple function...
54void recursion2(int level);
55
56void recursion(int level)
57{
58 q+=level;
59 if (level<5000)
60 recursion2(level+1);
61}
62
63void recursion2(int level)
64{
65 recursion(level);
66}
67
69{
70 ProfileHighLevel::Block b("Test block");
71 recursion(0);
72}
73
74void showResults(void)
75{
77 for (unsigned index=0;ProfileHighLevel::EnumProfile(index,id);index++)
78 printf("%-16s%-6s %s\n",id.GetName(),id.GetTotalValue(),id.GetUnit());
79}
80
81void main(void)
82{
83 for (int k=0;k<100;k++)
84 if (k%2&&k>80)
85 calcThat();
86 else
87 calcThis();
88
90
92}
93
94int q;
Timer based function block profile.
A high level profile ID.
static bool EnumProfile(unsigned index, Id &id)
Enumerates the list of known high level profile values.
void main(void)
Definition test1.cpp:47
const char * DebugGetDefaultCommands(void)
Determines default commands to be executed at startup.
Definition test1.cpp:31
void calcThis(void)
Definition test1.cpp:40
int q
Definition test1.cpp:94
void recursion2(int level)
Definition test1.cpp:63
void recursion(int level)
Definition test1.cpp:56
void recursionShell(void)
Definition test1.cpp:68
void calcThat(void)
Definition test1.cpp:45
void showResults(void)
Definition test1.cpp:74