Auxiliary class for CPU timing.
More...
#include <JClock.hh>
|
| struct | sentry |
| | Auxiliary data structure for scoped timing. More...
|
| |
|
| static void | sets (std::ostream &out) |
| | Set output stream.
|
| |
|
| static std::ostream *& | gets () |
| | Get output stream.
|
| |
|
| std::chrono::high_resolution_clock::time_point | t0 |
| |
| std::chrono::high_resolution_clock::time_point | t1 |
| |
| std::chrono::high_resolution_clock::duration | ts |
| |
| size_t | count |
| |
| std::string | title |
| |
|
| std::ostream & | operator<< (std::ostream &out, const JClock &clock) |
| | Print clock data.
|
| |
Auxiliary class for CPU timing.
Definition at line 23 of file JClock.hh.
◆ JClock() [1/2]
| JLANG::JClock::JClock |
( |
| ) |
|
|
inline |
Default constructor.
Definition at line 30 of file JClock.hh.
30 :
34 {}
std::chrono::high_resolution_clock::duration ts
JTitle()
Default constructor.
◆ JClock() [2/2]
| JLANG::JClock::JClock |
( |
const JTitle & | title | ) |
|
|
inline |
Constructor.
- Parameters
-
Definition at line 42 of file JClock.hh.
◆ ~JClock()
| JLANG::JClock::~JClock |
( |
| ) |
|
|
inline |
Destructor.
The clock data will optionally be printed to the set output stream.
Definition at line 54 of file JClock.hh.
55 {
57 *
gets() << (*this) << std::endl;
58 }
59 }
static std::ostream *& gets()
Get output stream.
◆ reset()
| void JLANG::JClock::reset |
( |
| ) |
|
|
inline |
Reset clock.
Definition at line 93 of file JClock.hh.
94 {
95 ts = std::chrono::high_resolution_clock::duration(0);
97 }
◆ start()
| void JLANG::JClock::start |
( |
| ) |
|
|
inline |
Start clock.
Definition at line 103 of file JClock.hh.
104 {
105 t0 = std::chrono::high_resolution_clock::now();
106 }
std::chrono::high_resolution_clock::time_point t0
◆ stop()
| void JLANG::JClock::stop |
( |
| ) |
|
|
inline |
Stop clock.
Definition at line 112 of file JClock.hh.
113 {
114 t1 = std::chrono::high_resolution_clock::now();
115
117
119 }
std::chrono::high_resolution_clock::time_point t1
◆ operator()()
| size_t JLANG::JClock::operator() |
( |
| ) |
const |
|
inline |
Get elapsed time.
- Returns
- elapsed time [ns]
Definition at line 127 of file JClock.hh.
128 {
129 return ts / std::chrono::nanoseconds(1);
130 }
◆ print()
| void JLANG::JClock::print |
( |
std::ostream & | out | ) |
const |
|
inline |
Print clock data.
- Parameters
-
Definition at line 138 of file JClock.hh.
139 {
141
142 out << setw(16) << left <<
getTitle() <<
' '
143 << setw(12) << right <<
count <<
' '
144 << setw(12) <<
ts / std::chrono::milliseconds(1) <<
" [ms]";
145 }
const std::string & getTitle() const
Get title.
◆ sets()
| static void JLANG::JClock::sets |
( |
std::ostream & | out | ) |
|
|
inlinestatic |
Set output stream.
- Parameters
-
Definition at line 168 of file JClock.hh.
◆ gets()
| static std::ostream *& JLANG::JClock::gets |
( |
| ) |
|
|
inlinestaticprotected |
Get output stream.
- Returns
- output stream
Definition at line 186 of file JClock.hh.
187 {
188 static std::ostream* out = NULL;
189
190 return out;
191 }
◆ getTitle()
| const std::string & JLANG::JTitle::getTitle |
( |
| ) |
const |
|
inlineinherited |
Get title.
- Returns
- title
Definition at line 55 of file JTitle.hh.
◆ setTitle()
| void JLANG::JTitle::setTitle |
( |
const std::string & | title | ) |
|
|
inlineinherited |
Set title.
- Parameters
-
Definition at line 66 of file JTitle.hh.
◆ operator<<
| std::ostream & operator<< |
( |
std::ostream & | out, |
|
|
const JClock & | clock ) |
|
friend |
Print clock data.
- Parameters
-
| out | output stream |
| clock | clock |
- Returns
- output stream
Definition at line 155 of file JClock.hh.
156 {
157 clock.print(out);
158
159 return out;
160 }
◆ t0
| std::chrono::high_resolution_clock::time_point JLANG::JClock::t0 |
|
protected |
◆ t1
| std::chrono::high_resolution_clock::time_point JLANG::JClock::t1 |
|
protected |
◆ ts
| std::chrono::high_resolution_clock::duration JLANG::JClock::ts |
|
protected |
◆ count
| size_t JLANG::JClock::count |
|
protected |
◆ title
| std::string JLANG::JTitle::title |
|
protectedinherited |
The documentation for this class was generated from the following file: