Auxiliary class for CPU timing.
More...
#include <JClock.hh>
|
| struct | sentry |
| | Auxiliary data structure for scoped timing. More...
|
| |
|
| 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 24 of file JClock.hh.
◆ JClock() [1/2]
| JLANG::JClock::JClock |
( |
| ) |
|
|
inline |
Default constructor.
Definition at line 31 of file JClock.hh.
31 :
35 {}
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 43 of file JClock.hh.
◆ reset()
| void JLANG::JClock::reset |
( |
| ) |
|
|
inline |
Reset clock.
Definition at line 81 of file JClock.hh.
82 {
83 ts = std::chrono::high_resolution_clock::duration(0);
85 }
◆ start()
| void JLANG::JClock::start |
( |
| ) |
|
|
inline |
Start clock.
Definition at line 91 of file JClock.hh.
92 {
93 t0 = std::chrono::high_resolution_clock::now();
94 }
std::chrono::high_resolution_clock::time_point t0
◆ stop()
| void JLANG::JClock::stop |
( |
| ) |
|
|
inline |
Stop clock.
Definition at line 100 of file JClock.hh.
101 {
102 t1 = std::chrono::high_resolution_clock::now();
103
105
107 }
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 115 of file JClock.hh.
116 {
117 return ts / std::chrono::nanoseconds(1);
118 }
◆ print()
| void JLANG::JClock::print |
( |
std::ostream & | out | ) |
const |
|
inline |
Print clock data.
- Parameters
-
Definition at line 126 of file JClock.hh.
127 {
129
130 out << setw(16) << left <<
getTitle() <<
' '
131 << setw(12) << right <<
count <<
' '
132 << setw(12) <<
ts / std::chrono::milliseconds(1) <<
" [ms]";
133 }
const std::string & getTitle() const
Get title.
◆ 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 143 of file JClock.hh.
144 {
145 clock.print(out);
146
147 return out;
148 }
◆ 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: