Manak  2.0.0
pmeasure.hpp
Go to the documentation of this file.
1 
7 #ifndef MANAK_PMEASURE_HPP_INCLUDED
8 #define MANAK_PMEASURE_HPP_INCLUDED
9 
10 #include <iostream>
11 #include <sstream>
12 
13 namespace manak
14 {
15 
19 struct PMeasure
20 {
26  : min(0), max(0), avg(0) {}
27 
35  PMeasure(double min, double max, double avg)
36  : min(min), max(max), avg(avg) {}
37 
39  int Compare(const double value, const double tolerance)
40  {
41  if(avg - value > tolerance)
42  return 1;
43  if(value - avg > tolerance)
44  return -1;
45  return 0;
46  }
47 
49  double min;
51  double max;
53  double avg;
54 };
55 
56 inline std::ostream& operator<<(std::ostream& stream, const PMeasure& pm)
57 {
58  std::stringstream s;
59  s << pm.avg;
60  stream << s.str();
61 
62  return stream;
63 }; // struct PMeasure
64 
65 }; // namespace manak
66 
67 
68 #endif // MANAK_PMEASURE_HPP_INCLUDED
int Compare(const double value, const double tolerance)
Compare the average with given value taking into consideration the tolerance.
Definition: pmeasure.hpp:39
std::ostream & operator<<(std::ostream &stream, const PMeasure &pm)
Definition: pmeasure.hpp:56
double avg
Average time.
Definition: pmeasure.hpp:53
Stores the timing information of any run.
Definition: pmeasure.hpp:19
double min
Minimum time.
Definition: pmeasure.hpp:49
PMeasure()
Create empty object For STL library use.
Definition: pmeasure.hpp:25
double max
Maximum time.
Definition: pmeasure.hpp:51
PMeasure(double min, double max, double avg)
Generate PMeasure object with given time information.
Definition: pmeasure.hpp:35