ITK  6.0.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  * https://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 "itkIndent.h"
23 #include "itkIntTypes.h"
24 
25 #include <iostream> // For cout.
26 #include <string>
27 #include <vector>
28 
29 #include "ITKCommonExport.h"
30 
31 namespace itk
32 {
44 template <typename ValueType, typename MeanType>
45 class ITK_TEMPLATE_EXPORT ResourceProbe
46 {
47 public:
51 
52 public:
54  ResourceProbe(std::string type, std::string unit);
55 
57  virtual ~ResourceProbe() = default;
58 
60  std::string
61  GetType() const;
62 
64  std::string
65  GetUnit() const;
66 
68  virtual void
69  Start();
70 
76  virtual void
77  Stop();
78 
80  CountType
81  GetNumberOfStarts() const;
82 
84  CountType
85  GetNumberOfStops() const;
86 
88  CountType
89  GetNumberOfIteration() const;
90 
93  virtual ValueType
94  GetInstantValue() const = 0;
95 
98  virtual ValueType
99  GetTotal() const;
100 
104  virtual MeanType
105  GetMean() const;
106 
108  virtual void
109  Reset();
110 
113  virtual ValueType
114  GetMinimum() const;
115 
118  virtual ValueType
119  GetMaximum() const;
120 
123  virtual ValueType
124  GetStandardDeviation();
125 
128  virtual ValueType
129  GetStandardError();
130 
132  virtual void
133  SetNameOfProbe(const char * nameOfProbe);
134 
136  virtual std::string
137  GetNameOfProbe() const;
138 
140  virtual void
141  PrintSystemInformation(std::ostream & os = std::cout);
142 
144  virtual void
145  Report(std::ostream & os = std::cout, bool printSystemInfo = true, bool printReportHead = true, bool useTabs = false);
146 
148  virtual void
149  ExpandedReport(std::ostream & os = std::cout,
150  bool printSystemInfo = true,
151  bool printReportHead = true,
152  bool useTabs = false);
153 
155  virtual void
156  JSONReport(std::ostream & os = std::cout);
157 
159  virtual void
160  PrintJSONSystemInformation(std::ostream & os = std::cout);
161 
162 protected:
164  virtual void
165  UpdateMinimumMaximumMeasuredValue(ValueType value);
166 
168  virtual void
169  PrintReportHead(std::ostream & os = std::cout, bool useTabs = false);
170 
172  virtual void
173  PrintExpandedReportHead(std::ostream & os = std::cout, bool useTabs = false);
174 
176  template <typename T>
177  void
178  PrintJSONvar(std::ostream & os, const char * varName, T varValue, unsigned int indent = 4, bool comma = true);
179 
181  virtual void
182  Print(std::ostream & os, Indent indent) const;
183 
184 private:
185  ValueType m_StartValue{};
186  ValueType m_TotalValue{};
187  ValueType m_MinimumValue{};
188  ValueType m_MaximumValue{};
189  ValueType m_StandardDeviation{};
190  ValueType m_StandardError{};
191 
192  CountType m_NumberOfStarts{};
193  CountType m_NumberOfStops{};
194  CountType m_NumberOfIteration{};
195 
196  std::vector<ValueType> m_ProbeValueList{};
197 
198  std::string m_NameOfProbe{};
199  std::string m_TypeString{};
200  std::string m_UnitString{};
201 
202  static constexpr unsigned int tabwidth = 15;
203 };
204 } // end namespace itk
205 
206 #ifndef ITK_MANUAL_INSTANTIATION
207 # include "itkResourceProbe.hxx"
208 #endif
209 
210 #endif // itkResourceProbe_h
itk::ResourceProbe< RealTimeClock::TimeStampType, RealTimeClock::TimeStampType >::CountType
SizeValueType CountType
Definition: itkResourceProbe.h:50
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ResourceProbe
Computes the change of a value between two points in code.
Definition: itkResourceProbe.h:45
itkMacro.h
itkIndent.h
itkIntTypes.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86