[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/AetherModel/aethermodel.github.io/main/report_8h_source.html [Back]  [Original]

Aether: include/report.h Source File
Aether  0.0
Ionosphere-Thermosphere model
report.h
1 // Copyright 2020, the Aether Development Team (see doc/dev_team.md for members)
2 // Full license can be found in License.md
3 
4 #ifndef INCLUDE_REPORT_H_
5 #define INCLUDE_REPORT_H_
6 
7 /**************************************************************
8  * \class Report
9  *
10  * \brief A system for reporting within the program
11 
12  This class allows users to manage reporting information to the
13  user, including debugging information (through a verbose level) and
14  timing information for parts of the code. There are functions for
15  capturing when the code goes into and out of a function to allow
16  for code tracing and timing.
17  *
18  * \author Aaron Ridley
19  *
20  * \date 2021/04/16
21  **************************************************************/
22 
23 #include <string>
24 #include <vector>
25 
26 #include "aether.h"
27 
28 class Report {
29 
30 // -----------------------------------------------------------------------
31 // Public functions and variables
32 // -----------------------------------------------------------------------
33 
34 public:
35 
36  // Functions:
37 
38  /**************************************************************
39  \brief Initialize all of the internal variables.
40  **/
41  Report();
42 
43  /**************************************************************
44  \brief This sets the global verbose level of the code
45 
46  The verbose level sets the amount of information presented to the
47  user of the code. Some thoughts on levels:
48  0 - essentially only report timing information
49  1 - report only broadest level of detail
50  2 - report going in and out of functions, and maybe things that are
51  done once per iteration
52  3-4 - Once per iteration types of outputs. More details at higher levels
53  5+ - get into grid iterations. Produces a HUGE amount of info.
54 
55  This verbose level should be set only on one processor. All other
56  processors should be set to -1.
57 
58  \param input global verbose level to set the code.
59  **/
60  void set_verbose(int input);
61 
62  /**************************************************************
63  \brief How deep to go in the timing report at the end of the run
64  \param input the timing depth to be set for the code
65  **/
66  void set_timing_depth(int input);
67 
68  /**************************************************************
69  \brief Print message if iLevel <= verbose level of code
70  \param iLevel test against verbose level of the code
71  \param output_string string to output if iLevel <= verbose level
72  **/
73  void print(int iLevel, std::string output_string);
74 
75  /**************************************************************
76  \brief Returns 1 if iLevel <= verbose level of code, 0 otherwise
77  \param iLevel test against verbose level of the code
78  **/
79  int test_verbose(int iLevel);
80 
81  /**************************************************************
82  \brief Returns the global verbosity of the code
83  **/
84  int get_verbose();
85 
86  /**************************************************************
87  \brief Starts timer and reports when entering a function, if applicable
88 
89  This is typically placed at the start of a function. This function
90  does the following:
91  - Figures out the depth of the function (which is compared to verbose level)
92  - Reports that it has entered function if the verbose level is high enough
93  - Starts a timer
94  - Records the name of the function and number of the function for exit.
95 
96  \param function_name The name of the function that is being entered
97  \param iFunction first time entered, this should be -1 or something,
98  then this is altered to be the number of the function.
99  when the function is called again, this number saves
100  a string compare
101  **/
102  void enter(std::string function_name, int &iFunction);
103 
104  /**************************************************************
105  \brief End the timer and reports exiting the function, see enter above
106  \param function_name The name of the function that is being exited
107  **/
108  void exit(std::string function_name);
109 
110  /**************************************************************
111  \brief Loop through all reported functions and report their run times
112  **/
113  void times();
114 
115 // -----------------------------------------------------------------------
116 // Private functions and variables
117 // -----------------------------------------------------------------------
118 private:
119 
121  int iVerbose;
123  int iTimingDepth;
124 
128  struct item_struct {
130  std::string entry;
132  int nTimes;
134  precision_t timing_total;
136  unsigned long long timing_start;
138  int iLevel;
140  int iStringPosBefore;
143  int iLastEntry;
144  };
145 
147  std::vector<item_struct> entries;
149  int nEntries;
151  std::string current_entry;
153  int iCurrentFunction = -1;
154 
156  std::string divider;
158  int divider_length;
159 
161  int iLevel;
162 
164  bool DoReportOnExit = false;
165 };
166 
167 #endif // INCLUDE_REPORT_H_
Report
Definition: report.h:28
Generated by   doxygen [doxygen] 1.8.17
Web Proxy Viewer  |  New URL  |  Original Page