test1.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /////////////////////////////////////////////////////////////////////////EA-V1
  19. // $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/test1/test1.cpp $
  20. // $Author: mhoffe $
  21. // $Revision: #3 $
  22. // $DateTime: 2003/07/09 10:57:23 $
  23. //
  24. // ©2003 Electronic Arts
  25. //
  26. // Profile module - Test 1 (basic testing)
  27. //////////////////////////////////////////////////////////////////////////////
  28. #include "../profile.h"
  29. #include "../../debug/debug.h"
  30. #include <stdio.h>
  31. const char *DebugGetDefaultCommands(void)
  32. {
  33. return "!debug.io con add\ndebug.add l + *\nprofile.result";
  34. }
  35. extern int q;
  36. void calcThis(void)
  37. {
  38. q++;
  39. }
  40. void calcThat(void)
  41. {
  42. calcThis();
  43. q--;
  44. }
  45. // it must be done this "complicated" because
  46. // otherwise VC does not generate a real recursive
  47. // function call for this simple function...
  48. void recursion2(int level);
  49. void recursion(int level)
  50. {
  51. q+=level;
  52. if (level<5000)
  53. recursion2(level+1);
  54. }
  55. void recursion2(int level)
  56. {
  57. recursion(level);
  58. }
  59. void recursionShell(void)
  60. {
  61. ProfileHighLevel::Block b("Test block");
  62. recursion(0);
  63. }
  64. void showResults(void)
  65. {
  66. ProfileHighLevel::Id id;
  67. for (unsigned index=0;ProfileHighLevel::EnumProfile(index,id);index++)
  68. printf("%-16s%-6s %s\n",id.GetName(),id.GetTotalValue(),id.GetUnit());
  69. }
  70. void main(void)
  71. {
  72. for (int k=0;k<100;k++)
  73. if (k%2&&k>80)
  74. calcThat();
  75. else
  76. calcThis();
  77. recursionShell();
  78. showResults();
  79. }
  80. int q;