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 /*=========================================================================
19  *
20  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  *  For complete copyright, license and disclaimer of warranty information
25  *  please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkResourceProbe_hxx
29 #define itkResourceProbe_hxx
30 
31 #include <numeric>
32 #include <iomanip>
33 #include <sstream>
34 #include <algorithm>
35 #include <functional>
36 #include <utility>
37 
38 #include "itkResourceProbe.h"
39 #include "itkNumericTraits.h"
40 #include "itksys/SystemInformation.hxx"
41 #include "itkMath.h"
42 #include "itkIsNumber.h"
43 
44 namespace itk
45 {
46 
47 template< typename ValueType, typename MeanType >
48 ResourceProbe< ValueType, MeanType >
ResourceProbe(std::string type,std::string unit)49 ::ResourceProbe(std::string  type, std::string  unit):
50   m_TypeString(std::move(type)), m_UnitString(std::move(unit))
51 {
52   this->Reset();
53 }
54 
55 template< typename ValueType, typename MeanType >
56 void
57 ResourceProbe< ValueType, MeanType >
Reset()58 ::Reset()
59 {
60   this->m_TotalValue        = NumericTraits< ValueType >::ZeroValue();
61   this->m_StartValue        = NumericTraits< ValueType >::ZeroValue();
62   this->m_MinimumValue      = NumericTraits< ValueType >::max();
63   this->m_MaximumValue      = NumericTraits< ValueType >::NonpositiveMin();
64   this->m_StandardDeviation = NumericTraits< ValueType >::ZeroValue();
65 
66   this->m_NumberOfStarts    = NumericTraits< CountType >::ZeroValue();
67   this->m_NumberOfStops     = NumericTraits< CountType >::ZeroValue();
68   this->m_NumberOfIteration = NumericTraits< CountType >::ZeroValue();
69 
70   this->m_ProbeValueList.clear();
71 }
72 
73 
74 template< typename ValueType, typename MeanType >
75 std::string
76 ResourceProbe< ValueType, MeanType >
GetType() const77 ::GetType() const
78 {
79   return this->m_TypeString;
80 }
81 
82 
83 template< typename ValueType, typename MeanType >
84 std::string
85 ResourceProbe< ValueType, MeanType >
GetUnit() const86 ::GetUnit() const
87 {
88   return this->m_UnitString;
89 }
90 
91 
92 template< typename ValueType, typename MeanType >
93 void
94 ResourceProbe< ValueType, MeanType >
Start()95 ::Start()
96 {
97   this->m_NumberOfStarts++;
98   this->m_StartValue = this->GetInstantValue();
99 }
100 
101 
102 template< typename ValueType, typename MeanType >
103 void
104 ResourceProbe< ValueType, MeanType >
Stop()105 ::Stop()
106 {
107   ValueType probevalue = this->GetInstantValue() - this->m_StartValue;
108   if ( this->m_NumberOfStops == this->m_NumberOfStarts )
109     {
110     return;
111     }
112 
113   this->UpdateMinimumMaximumMeasuredValue(probevalue);
114   this->m_TotalValue += probevalue;
115   this->m_ProbeValueList.push_back(probevalue);
116   this->m_NumberOfStops++;
117   this->m_NumberOfIteration = static_cast<CountType>(this->m_ProbeValueList.size());
118 }
119 
120 
121 template< typename ValueType, typename MeanType >
122 typename ResourceProbe< ValueType, MeanType >::CountType
123 ResourceProbe< ValueType, MeanType >
GetNumberOfStarts() const124 ::GetNumberOfStarts() const
125 {
126   return this->m_NumberOfStarts;
127 }
128 
129 
130 template< typename ValueType, typename MeanType >
131 typename ResourceProbe< ValueType, MeanType >::CountType
132 ResourceProbe< ValueType, MeanType >
GetNumberOfStops() const133 ::GetNumberOfStops() const
134 {
135   return this->m_NumberOfStops;
136 }
137 
138 
139 template< typename ValueType, typename MeanType >
140 typename ResourceProbe< ValueType, MeanType >::CountType
141 ResourceProbe< ValueType, MeanType >
GetNumberOfIteration() const142 ::GetNumberOfIteration() const
143 {
144   return this->m_NumberOfIteration;
145 }
146 
147 
148 template< typename ValueType, typename MeanType >
149 ValueType
150 ResourceProbe< ValueType, MeanType >
151 ::GetTotal() const
152 {
153   return this->m_TotalValue;
154 }
155 
156 
157 template< typename ValueType, typename MeanType >
158 MeanType
159 ResourceProbe< ValueType, MeanType >
GetMean() const160 ::GetMean() const
161 {
162   MeanType meanValue = NumericTraits< MeanType >::ZeroValue();
163 
164   if ( this->m_NumberOfStops )
165     {
166     meanValue = static_cast< MeanType >( this->m_TotalValue ) / static_cast< MeanType >( this->m_NumberOfStops );
167     }
168 
169   return meanValue;
170 }
171 
172 
173 template< typename ValueType, typename MeanType >
174 ValueType
175 ResourceProbe< ValueType, MeanType >
176 ::GetMinimum() const
177 {
178   return this->m_MinimumValue;
179 }
180 
181 
182 template< typename ValueType, typename MeanType >
183 ValueType
184 ResourceProbe< ValueType, MeanType >
185 ::GetMaximum() const
186 {
187   return this->m_MaximumValue;
188 }
189 
190 
191 template< typename ValueType, typename MeanType >
192 ValueType
193 ResourceProbe< ValueType, MeanType >
194 ::GetStandardDeviation()
195 {
196   using InternalComputeType = typename NumericTraits< ValueType >::RealType;
197   const InternalComputeType realMean = static_cast< InternalComputeType > ( this->GetMean() );
198   std::vector<InternalComputeType> diff(this->m_ProbeValueList.size());
199   std::transform(this->m_ProbeValueList.begin(),
200                  this->m_ProbeValueList.end(),
201                  diff.begin(),
202                  //Subtract mean from every value;
__anon003a84ad0102(const ValueType v ) 203                  [realMean] (const ValueType v ) { return ( static_cast< InternalComputeType > ( v ) - realMean ); }
204                  );
205   const InternalComputeType sqsum =
206     std::inner_product(diff.begin(),diff.end(),
207                        diff.begin(),
208                        NumericTraits< InternalComputeType >::ZeroValue());
209 
210   const InternalComputeType sz = static_cast<InternalComputeType>(this->m_ProbeValueList.size())-1.0;
211   if (sz <=0.0)
212     {
213     this->m_StandardDeviation = NumericTraits< ValueType >::ZeroValue();
214     }
215   else
216     {
217     this->m_StandardDeviation = static_cast<ValueType>(std::sqrt(sqsum /sz));
218     }
219   return this->m_StandardDeviation;
220 }
221 
222 
223 template< typename ValueType, typename MeanType >
224 ValueType
225 ResourceProbe< ValueType, MeanType >
226 ::GetStandardError()
227 {
228   const ValueType standardDeviation = this->GetStandardDeviation();
229   this->m_StandardError = static_cast< ValueType >( standardDeviation / std::sqrt( static_cast< double >( this->m_ProbeValueList.size() ) ) );
230   return this->m_StandardError;
231 }
232 
233 
234 template< typename ValueType, typename MeanType >
235 void
236 ResourceProbe< ValueType, MeanType >
SetNameOfProbe(const char * nameOfProbe)237 ::SetNameOfProbe(const char* nameOfProbe)
238 {
239   this->m_NameOfProbe = nameOfProbe;
240 }
241 
242 
243 template< typename ValueType, typename MeanType >
244 std::string
245 ResourceProbe< ValueType, MeanType >
GetNameOfProbe() const246 ::GetNameOfProbe() const
247 {
248   return this->m_NameOfProbe;
249 }
250 
251 template< typename ValueType, typename MeanType >
252 void
253 ResourceProbe< ValueType, MeanType >
PrintSystemInformation(std::ostream & os)254 ::PrintSystemInformation(std::ostream & os)
255 {
256   itksys::SystemInformation systeminfo;
257   systeminfo.RunCPUCheck();
258   systeminfo.RunMemoryCheck();
259   systeminfo.RunOSCheck();
260 
261   os << "System:              " << systeminfo.GetHostname() << std::endl;
262   os << "Processor:           " << systeminfo.GetExtendedProcessorName() << std::endl;
263   os << "    Cache:           " << systeminfo.GetProcessorCacheSize() << std::endl;
264   os << "    Clock:           " << systeminfo.GetProcessorClockFrequency() << std::endl;
265   os << "    Physical CPUs:   " << systeminfo.GetNumberOfPhysicalCPU() << std::endl;
266   os << "    Logical CPUs:    " << systeminfo.GetNumberOfLogicalCPU() << std::endl;
267   // Retrieve memory information in mebibytes.
268   os << "    Virtual Memory:  Total: "
269      << std::left << std::setw( tabwidth ) << systeminfo.GetTotalVirtualMemory()
270      <<" Available: "<< systeminfo.GetAvailableVirtualMemory() << std::endl;
271   os << "    Physical Memory: Total: "
272      << std::left << std::setw( tabwidth ) << systeminfo.GetTotalPhysicalMemory()
273      <<" Available: "<< systeminfo.GetAvailablePhysicalMemory() << std::endl;
274 
275   os << "OSName:              "<< systeminfo.GetOSName() << std::endl;
276   os << "    Release:         "<< systeminfo.GetOSRelease() << std::endl;
277   os << "    Version:         "<< systeminfo.GetOSVersion() << std::endl;
278   os << "    Platform:        "<< systeminfo.GetOSPlatform() << std::endl;
279 
280   os << "    Operating System is "
281      << (systeminfo.Is64Bits()?"64 bit":"32 bit") << std::endl;
282 
283   os << "ITK Version: "
284      << ITK_VERSION_STRING << "." << ITK_VERSION_PATCH << std::endl;
285 }
286 
287 
288 template< typename ValueType, typename MeanType >
289 void
290 ResourceProbe< ValueType, MeanType >
Report(std::ostream & os,bool printSystemInfo,bool printReportHead,bool useTabs)291 ::Report(std::ostream & os, bool printSystemInfo, bool printReportHead, bool useTabs)
292 {
293   if(printSystemInfo)
294     {
295     this->PrintSystemInformation(os);
296     }
297 
298   if(printReportHead)
299     {
300     this->PrintReportHead(os, useTabs);
301     }
302 
303   std::stringstream ss;
304   if( useTabs )
305     {
306     ss << std::left << '\t' << this->m_NameOfProbe
307        << std::left << '\t' << this->m_NumberOfIteration
308        << std::left << '\t' << this->GetTotal()
309        << std::left << '\t' << this->GetMinimum()
310        << std::left << '\t' << this->GetMean()
311        << std::left << '\t' << this->GetMaximum()
312        << std::left << '\t' << this->GetStandardDeviation();
313     }
314   else
315     {
316     ss << std::left << std::setw( tabwidth *2 ) << this->m_NameOfProbe
317        << std::left << std::setw( tabwidth    ) << this->m_NumberOfIteration
318        << std::left << std::setw( tabwidth    ) << this->GetTotal()
319        << std::left << std::setw( tabwidth    ) << this->GetMinimum()
320        << std::left << std::setw( tabwidth    ) << this->GetMean()
321        << std::left << std::setw( tabwidth    ) << this->GetMaximum()
322        << std::left << std::setw( tabwidth    ) << this->GetStandardDeviation();
323     }
324   os << ss.str() << std::endl;
325 }
326 
327 
328 template< typename ValueType, typename MeanType >
329 void
330 ResourceProbe< ValueType, MeanType >
ExpandedReport(std::ostream & os,bool printSystemInfo,bool printReportHead,bool useTabs)331 ::ExpandedReport(std::ostream & os, bool printSystemInfo, bool printReportHead, bool useTabs)
332 {
333   if(printSystemInfo)
334     {
335     this->PrintSystemInformation(os);
336     }
337 
338   if(printReportHead)
339     {
340     this->PrintExpandedReportHead(os, useTabs);
341     }
342 
343   std::stringstream ss;
344 
345   ValueType ratioOfMeanToMinimum;
346   if(Math::ExactlyEquals( this->GetMinimum() , 0.0) )
347     {
348     ratioOfMeanToMinimum = NumericTraits<ValueType>::ZeroValue();
349     }
350   else
351     {
352     ratioOfMeanToMinimum = static_cast<ValueType>(this->GetMean())/this->GetMinimum();
353     }
354 
355   ValueType ratioOfMaximumToMean;
356   if(Math::ExactlyEquals( this->GetMean() , 0.0) )
357     {
358     ratioOfMaximumToMean = NumericTraits<ValueType>::ZeroValue();
359     }
360   else
361     {
362     ratioOfMaximumToMean = this->GetMaximum()/static_cast<ValueType>(this->GetMean());
363     }
364 
365  if( useTabs )
366     {
367     ss << std::left << '\t' << this->m_NameOfProbe
368        << std::left << '\t' << this->m_NumberOfIteration
369        << std::left << '\t' << this->GetTotal()
370        << std::left << '\t' << this->GetMinimum()
371        << std::left << '\t' << this->GetMean() - this->GetMinimum()
372        << std::left << '\t' << ratioOfMeanToMinimum*100
373        << std::left << '\t' << this->GetMean()
374        << std::left << '\t' << this->GetMaximum() - this->GetMean()
375        << std::left << '\t' << ratioOfMaximumToMean*100
376        << std::left << '\t' << this->GetMaximum()
377        << std::left << '\t' << this->GetMaximum() - this->GetMinimum()
378        << std::left << '\t' << this->GetStandardDeviation()
379        << std::left << '\t' << this->GetStandardError();
380     }
381  else
382     {
383     ss << std::left << std::setw( tabwidth *2 ) << this->m_NameOfProbe
384        << std::left << std::setw( tabwidth    ) << this->m_NumberOfIteration
385        << std::left << std::setw( tabwidth    ) << this->GetTotal()
386        << std::left << std::setw( tabwidth    ) << this->GetMinimum()
387        << std::left << std::setw( tabwidth    ) << this->GetMean() - this->GetMinimum()
388        << std::left << std::setw( tabwidth    ) << ratioOfMeanToMinimum*100
389        << std::left << std::setw( tabwidth    ) << this->GetMean()
390        << std::left << std::setw( tabwidth    ) << this->GetMaximum() - this->GetMean()
391        << std::left << std::setw( tabwidth    ) << ratioOfMaximumToMean*100
392        << std::left << std::setw( tabwidth    ) << this->GetMaximum()
393        << std::left << std::setw( tabwidth    ) << this->GetMaximum() - this->GetMinimum()
394        << std::left << std::setw( tabwidth    ) << this->GetStandardDeviation()
395        << std::left << std::setw( tabwidth    ) << this->GetStandardError();
396     }
397   os << ss.str() << std::endl;
398 }
399 
400 
401 template< typename ValueType, typename MeanType >
402 template<typename T>
403 void
404 ResourceProbe< ValueType, MeanType >
PrintJSONvar(std::ostream & os,const char * varName,T varValue,unsigned indent,bool comma)405 ::PrintJSONvar(std::ostream & os, const char* varName, T varValue,
406     unsigned indent, bool comma)
407 {
408   bool varIsNumber = mpl::IsNumber<T>::Value;
409   while (indent > 0)
410     {
411       os << ' ';
412       --indent;
413     }
414   if (varIsNumber) //no quotes around the value
415     {
416     os << '"' << varName << "\": " << varValue;
417     }
418   else //put quotes around the value
419     {
420     os << '"' << varName << "\": \"" << varValue << '"';
421     }
422   if (comma)
423     {
424     os << ',';
425     }
426   os << '\n'; //std::endl has a side-effect of flushing the stream
427 }
428 
429 template< typename ValueType, typename MeanType >
430 void
431 ResourceProbe< ValueType, MeanType >
JSONReport(std::ostream & os)432 ::JSONReport(std::ostream & os)
433 {
434   std::stringstream ss;
435 
436   ValueType ratioOfMeanToMinimum;
437   if(Math::ExactlyEquals( this->GetMinimum() , 0.0) )
438     {
439     ratioOfMeanToMinimum = NumericTraits<ValueType>::ZeroValue();
440     }
441   else
442     {
443     ratioOfMeanToMinimum = static_cast<ValueType>(this->GetMean())/this->GetMinimum();
444     }
445 
446   ValueType ratioOfMaximumToMean;
447   if(Math::ExactlyEquals( this->GetMean() , 0.0) )
448     {
449     ratioOfMaximumToMean = NumericTraits<ValueType>::ZeroValue();
450     }
451   else
452     {
453     ratioOfMaximumToMean = this->GetMaximum()/static_cast<ValueType>(this->GetMean());
454     }
455 
456   os << "  {\n";
457   PrintJSONvar(os, "Name", m_NameOfProbe);
458   PrintJSONvar(os, "Type", m_TypeString);
459   PrintJSONvar(os, "Iterations", m_NumberOfIteration);
460   PrintJSONvar(os, "Units", m_UnitString);
461 
462   PrintJSONvar(os, "Mean", this->GetMean());
463   PrintJSONvar(os, "Minimum", this->GetMinimum());
464   PrintJSONvar(os, "Maximum", this->GetMaximum());
465   PrintJSONvar(os, "Total", this->GetTotal());
466   PrintJSONvar(os, "StandardDeviation", this->GetStandardDeviation());
467   PrintJSONvar(os, "StandardError", this->GetStandardError());
468 
469   PrintJSONvar(os, "TotalDifference", this->GetMaximum() - this->GetMinimum());
470   PrintJSONvar(os, "MeanMinimumDifference", this->GetMean() - this->GetMinimum());
471   PrintJSONvar(os, "MeanMinimumDifferencePercent", ratioOfMeanToMinimum * 100);
472   PrintJSONvar(os, "MaximumMeanDifference", this->GetMaximum() - this->GetMean());
473   PrintJSONvar(os, "MaximumMeanDifferencePercent", ratioOfMaximumToMean * 100, 4, false);
474   os << "  }";
475 }
476 
477 
478 template< typename ValueType, typename MeanType >
479 void
480 ResourceProbe< ValueType, MeanType >
UpdateMinimumMaximumMeasuredValue(ValueType value)481 ::UpdateMinimumMaximumMeasuredValue(ValueType value)
482 {
483   if(this->m_MinimumValue > value)
484     {
485     this->m_MinimumValue = value;
486     }
487 
488   if(this->m_MaximumValue < value)
489     {
490     this->m_MaximumValue = value;
491     }
492 }
493 
494 
495 template< typename ValueType, typename MeanType >
496 void
497 ResourceProbe< ValueType, MeanType >
PrintReportHead(std::ostream & os,bool useTabs)498 ::PrintReportHead(std::ostream & os, bool useTabs)
499 {
500   std::stringstream ss;
501   if( useTabs )
502     {
503     ss << std::left << '\t' << std::string("Name Of Probe (")+this->m_TypeString + std::string(")")
504        << std::left << '\t' << "Iterations"
505        << std::left << '\t' << std::string("Total (") + this->m_UnitString + std::string(")")
506        << std::left << '\t' << std::string("Min (") + this->m_UnitString + std::string(")")
507        << std::left << '\t' << std::string("Mean (") + this->m_UnitString + std::string(")")
508        << std::left << '\t' << std::string("Max (") + this->m_UnitString + std::string(")")
509        << std::left << '\t' << std::string("StdDev (") + this->m_UnitString + std::string(")");
510     }
511   else
512     {
513     ss << std::left << std::setw( tabwidth *2 ) << std::string("Name Of Probe (")+this->m_TypeString + std::string(")")
514        << std::left << std::setw( tabwidth    ) << "Iterations"
515        << std::left << std::setw( tabwidth    ) << std::string("Total (") + this->m_UnitString + std::string(")")
516        << std::left << std::setw( tabwidth    ) << std::string("Min (") + this->m_UnitString + std::string(")")
517        << std::left << std::setw( tabwidth    ) << std::string("Mean (") + this->m_UnitString + std::string(")")
518        << std::left << std::setw( tabwidth    ) << std::string("Max (") + this->m_UnitString + std::string(")")
519        << std::left << std::setw( tabwidth    ) << std::string("StdDev (") + this->m_UnitString + std::string(")");
520     }
521 
522   os << ss.str() << std::endl;
523 }
524 
525 
526 template< typename ValueType, typename MeanType >
527 void
528 ResourceProbe< ValueType, MeanType >
PrintExpandedReportHead(std::ostream & os,bool useTabs)529 ::PrintExpandedReportHead(std::ostream & os, bool useTabs)
530 {
531   std::stringstream ss;
532   if( useTabs )
533     {
534     ss << std::left << '\t' << std::string("Name Of Probe (") + this->m_TypeString + std::string(")")
535        << std::left << '\t' << "Iterations"
536        << std::left << '\t' << std::string("Total (") + this->m_UnitString + std::string(")")
537        << std::left << '\t' << std::string("Min (") + this->m_UnitString + std::string(")")
538        << std::left << '\t' << "Mean-Min (diff)"
539        << std::left << '\t' << "Mean/Min (%)"
540        << std::left << '\t' << std::string("Mean (") + this->m_UnitString + std::string(")")
541        << std::left << '\t' << "Max-Mean (diff)"
542        << std::left << '\t' << "Max/Mean (%)"
543        << std::left << '\t' << std::string("Max (") + this->m_UnitString + std::string(")")
544        << std::left << '\t' << std::string("Total Diff (") + this->m_UnitString + std::string(")")
545        << std::left << '\t' << std::string("StdDev (") + this->m_UnitString + std::string(")")
546        << std::left << '\t' << std::string("StdErr (") + this->m_UnitString + std::string(")");
547     }
548   else
549     {
550     ss << std::left << std::setw( tabwidth *2 ) << std::string("Name Of Probe (") + this->m_TypeString + std::string(")")
551        << std::left << std::setw( tabwidth    ) << "Iterations"
552        << std::left << std::setw( tabwidth    ) << std::string("Total (") + this->m_UnitString + std::string(")")
553        << std::left << std::setw( tabwidth    ) << std::string("Min (") + this->m_UnitString + std::string(")")
554        << std::left << std::setw( tabwidth    ) << "Mean-Min (diff)"
555        << std::left << std::setw( tabwidth    ) << "Mean/Min (%)"
556        << std::left << std::setw( tabwidth    ) << std::string("Mean (") + this->m_UnitString + std::string(")")
557        << std::left << std::setw( tabwidth    ) << "Max-Mean (diff)"
558        << std::left << std::setw( tabwidth    ) << "Max/Mean (%)"
559        << std::left << std::setw( tabwidth    ) << std::string("Max (") + this->m_UnitString + std::string(")")
560        << std::left << std::setw( tabwidth    ) << std::string("Total Diff (") + this->m_UnitString + std::string(")")
561        << std::left << std::setw( tabwidth    ) << std::string("StdDev (") + this->m_UnitString + std::string(")")
562        << std::left << std::setw( tabwidth    ) << std::string("StdErr (") + this->m_UnitString + std::string(")");
563     }
564 
565   os << ss.str() << std::endl;
566 }
567 
568 
569 template< typename ValueType, typename MeanType >
570 void
571 ResourceProbe< ValueType, MeanType >
PrintJSONSystemInformation(std::ostream & os)572 ::PrintJSONSystemInformation(std::ostream & os)
573 {
574   itksys::SystemInformation systeminfo;
575   systeminfo.RunCPUCheck();
576   systeminfo.RunMemoryCheck();
577   systeminfo.RunOSCheck();
578 
579   os << "{\n";
580   PrintJSONvar(os, "System", systeminfo.GetHostname());
581 
582   os << "    \"Processor\" :{\n";
583   PrintJSONvar(os, "Name", systeminfo.GetExtendedProcessorName(), 6);
584   PrintJSONvar(os, "Cache", systeminfo.GetProcessorCacheSize(), 6);
585   PrintJSONvar(os, "Clock", systeminfo.GetProcessorClockFrequency(), 6);
586   PrintJSONvar(os, "Physical CPUs", systeminfo.GetNumberOfPhysicalCPU(), 6);
587   PrintJSONvar(os, "Logical CPUs", systeminfo.GetNumberOfLogicalCPU(), 6);
588   PrintJSONvar(os, "Virtual Memory Total", systeminfo.GetTotalVirtualMemory(), 6);
589   PrintJSONvar(os, "Virtual Memory Available", systeminfo.GetAvailableVirtualMemory(), 6);
590   PrintJSONvar(os, "Physical Memory Total", systeminfo.GetTotalPhysicalMemory(), 6);
591   PrintJSONvar(os, "Physical Memory Available", systeminfo.GetAvailablePhysicalMemory(), 6, false);
592   os << "    },\n";
593 
594   os << "    \"OperatingSystem\" :{\n";
595   PrintJSONvar(os, "Name", systeminfo.GetOSName(), 6);
596   PrintJSONvar(os, "Release", systeminfo.GetOSRelease(), 6);
597   PrintJSONvar(os, "Version", systeminfo.GetOSVersion(), 6);
598   PrintJSONvar(os, "Platform", systeminfo.GetOSPlatform(), 6);
599   PrintJSONvar(os, "Bitness", (systeminfo.Is64Bits() ? "64 bit" : "32 bit"), 6, false);
600   os << "    },\n";
601 
602   std::ostringstream itkVersionStringStream;
603   itkVersionStringStream << ITK_VERSION_STRING << "." << ITK_VERSION_PATCH;
604 
605   PrintJSONvar(os, "ITKVersion", itkVersionStringStream.str(), 4, false);
606   os << "  }";
607 }
608 
609 
610 // This protected member function that was introduced with ITK 4.8 has been deprecated
611 // as of ITK 5.0. Please do not call or override this member function.
612 #if !defined(ITK_LEGACY_REMOVE)
613 template< typename ValueType, typename MeanType >
614 void
615 ResourceProbe< ValueType, MeanType >
GetSystemInformation()616 ::GetSystemInformation()
617 {
618 }
619 #endif
620 
621 } // end namespace itk
622 
623 #endif
624