SW Class Reference

#include "sw.h"

Public Member Functions

SW (std::string description)
void start (void)
void stop (void)
~SW ()
SW (std::string description)
void start (void)
void stop (void)
~SW ()
SW (std::string description)
void start (void)
void stop (void)
~SW ()

Detailed Description

Constructor & Destructor Documentation

SW() [1/3]

SW::SW ( std::string description )
inline
47 : n (0), sum (0), sum2 (0), m_min ((uint64_t) -1), m_max (0), description (description)
48 {
49 }

~SW() [1/3]

SW::~SW ( )
inline
90 {
91using namespace std;
92double units = 1000000000;
93const double average = n ? (double) sum / units / n : 0.0;
94const double standardDeviation =
95 n > 2 ? std::sqrt (((double) sum2 / units / units - (double) sum / units * sum / units / n) / (n - 1)) : 0.0;
96const double m_minimum = n ? (double) m_min / units : 0.0;
97const double m_maximum = (double) m_max / units;
98const double total = (double) sum / units;
99
100if (n > 0)
101 {
102 cout << fixed << setprecision(9);
103 cout << (double) average << " +/- " << standardDeviation << " [" << m_minimum << ", " << m_maximum << "], n: " << setw(4) << n
104 << ", total: " << total << ", " << description << endl;
105 }
106 }

SW() [2/3]

SW::SW ( std::string description )
inline
47 : n (0), sum (0), sum2 (0), m_min ((uint64_t) -1), m_max (0), description (description)
48 {
49 }

~SW() [2/3]

SW::~SW ( )
inline
90 {
91using namespace std;
92double units = 1000000000;
93const double average = n ? (double) sum / units / n : 0.0;
94const double standardDeviation =
95 n > 2 ? std::sqrt (((double) sum2 / units / units - (double) sum / units * sum / units / n) / (n - 1)) : 0.0;
96const double m_minimum = n ? (double) m_min / units : 0.0;
97const double m_maximum = (double) m_max / units;
98const double total = (double) sum / units;
99
100if (n > 0)
101 {
102 cout << fixed << setprecision(9);
103 cout << (double) average << " +/- " << standardDeviation << " [" << m_minimum << ", " << m_maximum << "], n: " << setw(4) << n
104 << ", total: " << total << ", " << description << endl;
105 }
106 }

SW() [3/3]

SW::SW ( std::string description )
inline
47 : n (0), sum (0), sum2 (0), m_min ((uint64_t) -1), m_max (0), description (description)
48 {
49 }

~SW() [3/3]

SW::~SW ( )
inline
90 {
91using namespace std;
92double units = 1000000000;
93const double average = n ? (double) sum / units / n : 0.0;
94const double standardDeviation =
95 n > 2 ? std::sqrt (((double) sum2 / units / units - (double) sum / units * sum / units / n) / (n - 1)) : 0.0;
96const double m_minimum = n ? (double) m_min / units : 0.0;
97const double m_maximum = (double) m_max / units;
98const double total = (double) sum / units;
99
100if (n > 0)
101 {
102 cout << fixed << setprecision(9);
103 cout << (double) average << " +/- " << standardDeviation << " [" << m_minimum << ", " << m_maximum << "], n: " << setw(4) << n
104 << ", total: " << total << ", " << description << endl;
105 }
106 }

Member Function Documentation

start() [1/3]

void SW::start ( void )
inline
Examples
cpp50Example_main.cpp, and cpp55Example_main.cpp.
57 {
58 stamp = std::chrono::high_resolution_clock::now();
59 }

start() [2/3]

void SW::start ( void )
inline
57 {
58 stamp = std::chrono::high_resolution_clock::now();
59 }

start() [3/3]

void SW::start ( void )
inline
57 {
58 stamp = std::chrono::high_resolution_clock::now();
59 }

stop() [1/3]

void SW::stop ( void )
inline
Examples
cpp50Example_main.cpp, and cpp55Example_main.cpp.
69 {
70 uint64_t measurement = std::chrono::duration_cast< std::chrono::nanoseconds >
71 (std::chrono::high_resolution_clock::now() - stamp).count ();
72 n++;
73if (measurement > m_max)
74 {
75 m_max = measurement;
76 }
77if (measurement < m_min)
78 {
79 m_min = measurement;
80 }
81 sum += measurement;
82 sum2 += measurement * measurement;
83 }

stop() [2/3]

void SW::stop ( void )
inline
69 {
70 uint64_t measurement = std::chrono::duration_cast< std::chrono::nanoseconds >
71 (std::chrono::high_resolution_clock::now() - stamp).count ();
72 n++;
73if (measurement > m_max)
74 {
75 m_max = measurement;
76 }
77if (measurement < m_min)
78 {
79 m_min = measurement;
80 }
81 sum += measurement;
82 sum2 += measurement * measurement;
83 }

stop() [3/3]

void SW::stop ( void )
inline
69 {
70 uint64_t measurement = std::chrono::duration_cast< std::chrono::nanoseconds >
71 (std::chrono::high_resolution_clock::now() - stamp).count ();
72 n++;
73if (measurement > m_max)
74 {
75 m_max = measurement;
76 }
77if (measurement < m_min)
78 {
79 m_min = measurement;
80 }
81 sum += measurement;
82 sum2 += measurement * measurement;
83 }

The documentation for this class was generated from the following file: