ITK  5.0.0
Insight Segmentation and Registration 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:
46 
50 
51 public:
52 
54  ResourceProbe(std::string type, std::string unit);
55 
57  virtual ~ResourceProbe() = default;
58 
60  std::string GetType() const;
61 
63  std::string GetUnit() const;
64 
66  virtual void Start();
67 
73  virtual void Stop();
74 
76  CountType GetNumberOfStarts() const;
77 
79  CountType GetNumberOfStops() const;
80 
82  CountType GetNumberOfIteration() const;
83 
86  virtual ValueType GetInstantValue() const = 0;
87 
90  virtual ValueType GetTotal() const;
91 
95  virtual MeanType GetMean() const;
96 
98  virtual void Reset();
99 
102  virtual ValueType GetMinimum() const;
103 
106  virtual ValueType GetMaximum() const;
107 
110  virtual ValueType GetStandardDeviation();
111 
114  virtual ValueType GetStandardError();
115 
117  virtual void SetNameOfProbe(const char* nameOfProbe);
118 
120  virtual std::string GetNameOfProbe() const;
121 
123  virtual void PrintSystemInformation(std::ostream & os = std::cout);
124 
126  virtual void Report(std::ostream & os = std::cout, bool printSystemInfo = true,
127  bool printReportHead = true, bool useTabs = false);
128 
130  virtual void ExpandedReport(std::ostream & os = std::cout, bool printSystemInfo = true,
131  bool printReportHead = true, bool useTabs = false);
132 
134  virtual void JSONReport(std::ostream & os = std::cout);
135 
137  virtual void PrintJSONSystemInformation(std::ostream & os = std::cout);
138 
139 protected:
141  virtual void UpdateMinimumMaximumMeasuredValue(ValueType value);
142 
144  virtual void PrintReportHead(std::ostream & os = std::cout, bool useTabs = false);
145 
147  virtual void PrintExpandedReportHead(std::ostream & os = std::cout, bool useTabs = false);
148 
150  template<typename T>
151  void PrintJSONvar(std::ostream & os, const char* varName, T varValue,
152  unsigned indent = 4, bool comma = true);
153 
155  itkLegacyMacro(virtual void GetSystemInformation());
156 
157 private:
158 
159  ValueType m_StartValue;
160  ValueType m_TotalValue;
161  ValueType m_MinimumValue;
162  ValueType m_MaximumValue;
164  ValueType m_StandardError;
165 
169 
170  std::vector<ValueType> m_ProbeValueList;
171 
172  std::string m_NameOfProbe;
173  std::string m_TypeString;
174  std::string m_UnitString;
175 
176  static constexpr unsigned int tabwidth = 15;
177 };
178 } // end namespace itk
179 
180 #ifndef ITK_MANUAL_INSTANTIATION
181 #include "itkResourceProbe.hxx"
182 #endif
183 
184 #endif //itkResourceProbe_h
unsigned long SizeValueType
Definition: itkIntTypes.h:83
ValueType m_StandardDeviation
std::string m_TypeString
std::string m_UnitString
std::string m_NameOfProbe
CountType m_NumberOfIteration
std::vector< ValueType > m_ProbeValueList
Computes the change of a value between two points in code.