ITK  5.1.0
Insight Toolkit
itkResourceProbe.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 <string>
25 #include <vector>
26 
27 #include "ITKCommonExport.h"
28 
29 namespace itk
30 {
42 template <typename ValueType, typename MeanType>
43 class ITK_TEMPLATE_EXPORT ResourceProbe
44 {
45 public:
49 
50 public:
52  ResourceProbe(std::string type, std::string unit);
53 
55  virtual ~ResourceProbe() = default;
56 
58  std::string
59  GetType() const;
60 
62  std::string
63  GetUnit() const;
64 
66  virtual void
67  Start();
68 
74  virtual void
75  Stop();
76 
78  CountType
79  GetNumberOfStarts() const;
80 
82  CountType
83  GetNumberOfStops() const;
84 
86  CountType
87  GetNumberOfIteration() const;
88 
91  virtual ValueType
92  GetInstantValue() const = 0;
93 
96  virtual ValueType
97  GetTotal() const;
98 
102  virtual MeanType
103  GetMean() const;
104 
106  virtual void
107  Reset();
108 
111  virtual ValueType
112  GetMinimum() const;
113 
116  virtual ValueType
117  GetMaximum() const;
118 
121  virtual ValueType
122  GetStandardDeviation();
123 
126  virtual ValueType
127  GetStandardError();
128 
130  virtual void
131  SetNameOfProbe(const char * nameOfProbe);
132 
134  virtual std::string
135  GetNameOfProbe() const;
136 
138  virtual void
139  PrintSystemInformation(std::ostream & os = std::cout);
140 
142  virtual void
143  Report(std::ostream & os = std::cout, bool printSystemInfo = true, bool printReportHead = true, bool useTabs = false);
144 
146  virtual void
147  ExpandedReport(std::ostream & os = std::cout,
148  bool printSystemInfo = true,
149  bool printReportHead = true,
150  bool useTabs = false);
151 
153  virtual void
154  JSONReport(std::ostream & os = std::cout);
155 
157  virtual void
158  PrintJSONSystemInformation(std::ostream & os = std::cout);
159 
160 protected:
162  virtual void
163  UpdateMinimumMaximumMeasuredValue(ValueType value);
164 
166  virtual void
167  PrintReportHead(std::ostream & os = std::cout, bool useTabs = false);
168 
170  virtual void
171  PrintExpandedReportHead(std::ostream & os = std::cout, bool useTabs = false);
172 
174  template <typename T>
175  void
176  PrintJSONvar(std::ostream & os, const char * varName, T varValue, unsigned indent = 4, bool comma = true);
177 
179  itkLegacyMacro(virtual void GetSystemInformation());
180 
181 private:
182  ValueType m_StartValue;
183  ValueType m_TotalValue;
184  ValueType m_MinimumValue;
185  ValueType m_MaximumValue;
187  ValueType m_StandardError;
188 
192 
193  std::vector<ValueType> m_ProbeValueList;
194 
195  std::string m_NameOfProbe;
196  std::string m_TypeString;
197  std::string m_UnitString;
198 
199  static constexpr unsigned int tabwidth = 15;
200 };
201 } // end namespace itk
202 
203 #ifndef ITK_MANUAL_INSTANTIATION
204 # include "itkResourceProbe.hxx"
205 #endif
206 
207 #endif // itkResourceProbe_h
itk::ResourceProbe::m_NameOfProbe
std::string m_NameOfProbe
Definition: itkResourceProbe.h:195
itk::ResourceProbe::m_MinimumValue
ValueType m_MinimumValue
Definition: itkResourceProbe.h:184
itk::ResourceProbe< RealTimeClock::TimeStampType, RealTimeClock::TimeStampType >::CountType
SizeValueType CountType
Definition: itkResourceProbe.h:48
itk::ResourceProbe::m_NumberOfIteration
CountType m_NumberOfIteration
Definition: itkResourceProbe.h:191
itk::ResourceProbe::m_TypeString
std::string m_TypeString
Definition: itkResourceProbe.h:196
itk::ResourceProbe::m_NumberOfStarts
CountType m_NumberOfStarts
Definition: itkResourceProbe.h:189
itk::ResourceProbe::m_StartValue
ValueType m_StartValue
Definition: itkResourceProbe.h:182
itk::ResourceProbe::m_TotalValue
ValueType m_TotalValue
Definition: itkResourceProbe.h:183
itk::ResourceProbe
Computes the change of a value between two points in code.
Definition: itkResourceProbe.h:43
itk::ResourceProbe::m_UnitString
std::string m_UnitString
Definition: itkResourceProbe.h:197
itkMacro.h
itk::ResourceProbe::m_MaximumValue
ValueType m_MaximumValue
Definition: itkResourceProbe.h:185
itk::ResourceProbe::m_NumberOfStops
CountType m_NumberOfStops
Definition: itkResourceProbe.h:190
itk::ResourceProbe::m_ProbeValueList
std::vector< ValueType > m_ProbeValueList
Definition: itkResourceProbe.h:193
itkIntTypes.h
itk::ResourceProbe::m_StandardDeviation
ValueType m_StandardDeviation
Definition: itkResourceProbe.h:186
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ResourceProbe::m_StandardError
ValueType m_StandardError
Definition: itkResourceProbe.h:187
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83