ITK  5.3.0
Insight Toolkit
itkResourceProbe.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkResourceProbe_h
19 #define itkResourceProbe_h
20 
21 #include "itkMacro.h"
22 #include "itkIntTypes.h"
23 
24 #include <iostream> // For cout.
25 #include <string>
26 #include <vector>
27 
28 #include "ITKCommonExport.h"
29 
30 namespace itk
31 {
43 template <typename ValueType, typename MeanType>
44 class ITK_TEMPLATE_EXPORT ResourceProbe
45 {
46 public:
50 
51 public:
53  ResourceProbe(std::string type, std::string unit);
54 
56  virtual ~ResourceProbe() = default;
57 
59  std::string
60  GetType() const;
61 
63  std::string
64  GetUnit() const;
65 
67  virtual void
68  Start();
69 
75  virtual void
76  Stop();
77 
79  CountType
80  GetNumberOfStarts() const;
81 
83  CountType
84  GetNumberOfStops() const;
85 
87  CountType
88  GetNumberOfIteration() const;
89 
92  virtual ValueType
93  GetInstantValue() const = 0;
94 
97  virtual ValueType
98  GetTotal() const;
99 
103  virtual MeanType
104  GetMean() const;
105 
107  virtual void
108  Reset();
109 
112  virtual ValueType
113  GetMinimum() const;
114 
117  virtual ValueType
118  GetMaximum() const;
119 
122  virtual ValueType
123  GetStandardDeviation();
124 
127  virtual ValueType
128  GetStandardError();
129 
131  virtual void
132  SetNameOfProbe(const char * nameOfProbe);
133 
135  virtual std::string
136  GetNameOfProbe() const;
137 
139  virtual void
140  PrintSystemInformation(std::ostream & os = std::cout);
141 
143  virtual void
144  Report(std::ostream & os = std::cout, bool printSystemInfo = true, bool printReportHead = true, bool useTabs = false);
145 
147  virtual void
148  ExpandedReport(std::ostream & os = std::cout,
149  bool printSystemInfo = true,
150  bool printReportHead = true,
151  bool useTabs = false);
152 
154  virtual void
155  JSONReport(std::ostream & os = std::cout);
156 
158  virtual void
159  PrintJSONSystemInformation(std::ostream & os = std::cout);
160 
161 protected:
163  virtual void
164  UpdateMinimumMaximumMeasuredValue(ValueType value);
165 
167  virtual void
168  PrintReportHead(std::ostream & os = std::cout, bool useTabs = false);
169 
171  virtual void
172  PrintExpandedReportHead(std::ostream & os = std::cout, bool useTabs = false);
173 
175  template <typename T>
176  void
177  PrintJSONvar(std::ostream & os, const char * varName, T varValue, unsigned indent = 4, bool comma = true);
178 
180  itkLegacyMacro(virtual void GetSystemInformation());
181 
182 private:
183  ValueType m_StartValue;
184  ValueType m_TotalValue;
185  ValueType m_MinimumValue;
186  ValueType m_MaximumValue;
188  ValueType m_StandardError;
189 
193 
194  std::vector<ValueType> m_ProbeValueList;
195 
196  std::string m_NameOfProbe;
197  std::string m_TypeString;
198  std::string m_UnitString;
199 
200  static constexpr unsigned int tabwidth = 15;
201 };
202 } // end namespace itk
203 
204 #ifndef ITK_MANUAL_INSTANTIATION
205 # include "itkResourceProbe.hxx"
206 #endif
207 
208 #endif // itkResourceProbe_h
itk::ResourceProbe::m_NameOfProbe
std::string m_NameOfProbe
Definition: itkResourceProbe.h:196
itk::ResourceProbe::m_MinimumValue
ValueType m_MinimumValue
Definition: itkResourceProbe.h:185
itk::ResourceProbe< RealTimeClock::TimeStampType, RealTimeClock::TimeStampType >::CountType
SizeValueType CountType
Definition: itkResourceProbe.h:49
itk::ResourceProbe::m_NumberOfIteration
CountType m_NumberOfIteration
Definition: itkResourceProbe.h:192
itk::ResourceProbe::m_TypeString
std::string m_TypeString
Definition: itkResourceProbe.h:197
itk::ResourceProbe::m_NumberOfStarts
CountType m_NumberOfStarts
Definition: itkResourceProbe.h:190
itk::ResourceProbe::m_StartValue
ValueType m_StartValue
Definition: itkResourceProbe.h:183
itk::ResourceProbe::m_TotalValue
ValueType m_TotalValue
Definition: itkResourceProbe.h:184
itk::ResourceProbe
Computes the change of a value between two points in code.
Definition: itkResourceProbe.h:44
itk::ResourceProbe::m_UnitString
std::string m_UnitString
Definition: itkResourceProbe.h:198
itkMacro.h
itk::ResourceProbe::m_MaximumValue
ValueType m_MaximumValue
Definition: itkResourceProbe.h:186
itk::ResourceProbe::m_NumberOfStops
CountType m_NumberOfStops
Definition: itkResourceProbe.h:191
itk::ResourceProbe::m_ProbeValueList
std::vector< ValueType > m_ProbeValueList
Definition: itkResourceProbe.h:194
itkIntTypes.h
itk::ResourceProbe::m_StandardDeviation
ValueType m_StandardDeviation
Definition: itkResourceProbe.h:187
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ResourceProbe::m_StandardError
ValueType m_StandardError
Definition: itkResourceProbe.h:188
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83