internal_result.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/internal_result.h $
  20. // $Author: mhoffe $
  21. // $Revision: #1 $
  22. // $DateTime: 2003/07/09 10:57:23 $
  23. //
  24. // ©2003 Electronic Arts
  25. //
  26. // Internal result functions
  27. //////////////////////////////////////////////////////////////////////////////
  28. #ifdef _MSC_VER
  29. # pragma once
  30. #endif
  31. #ifndef INTERNAL_RESULT_H // Include guard
  32. #define INTERNAL_RESULT_H
  33. /// \brief Simple CSV format flat file result function, for all threads.
  34. class ProfileResultFileCSV: public ProfileResultInterface
  35. {
  36. ProfileResultFileCSV(void) {}
  37. void WriteThread(ProfileFuncLevel::Thread &thread);
  38. public:
  39. static ProfileResultInterface *Create(int argn, const char * const *);
  40. virtual const char *GetName(void) const { return "file_csv"; }
  41. virtual void WriteResults(void);
  42. virtual void Delete(void);
  43. };
  44. /**
  45. \brief Write out DOT file for calling hierarchy.
  46. The frame name and the file name must be specified when creating an
  47. instance of this result function. The result function will always pick
  48. the thread with the highest function count (which is usually the
  49. main thread).
  50. \note A DOT file is used with the DOT tool from the GraphViz package
  51. for generating directed graphs, e.g. by issuing dot -Tgif -ograph.gif profile.dot
  52. */
  53. class ProfileResultFileDOT: public ProfileResultInterface
  54. {
  55. public:
  56. enum
  57. {
  58. MAX_FUNCTIONS_PER_FILE = 200
  59. };
  60. /**
  61. \brief Creates a class instance.
  62. \param fileName name of DOT file to generate (defaults to profile.dot)
  63. \param frameName name of frame to use (NULL for global)
  64. \param foldThreshold if the number of functions exceeds the given threshold
  65. then all functions belonging to the same source file
  66. will be folded into a single entry
  67. \return new instance
  68. */
  69. static ProfileResultInterface *Create(int argn, const char * const *);
  70. virtual const char *GetName(void) const { return "file_dot"; }
  71. virtual void WriteResults(void);
  72. virtual void Delete(void);
  73. private:
  74. ProfileResultFileDOT(const char *fileName, const char *frameName, int foldThreshold);
  75. struct FoldHelper
  76. {
  77. FoldHelper *next;
  78. const char *source;
  79. ProfileFuncLevel::Id id[MAX_FUNCTIONS_PER_FILE];
  80. unsigned numId;
  81. bool mark;
  82. };
  83. char *m_fileName;
  84. char *m_frameName;
  85. int m_foldThreshold;
  86. };
  87. #endif // INTERNAL_RESULT_H