#include <nimble.quanta.stopwatch.h>
|
typedef decltype(std::chrono::high_resolution_clock::now()) | time |
|
typedef std::chrono::duration< double, std::ratio< 1, 1 > > | seconds |
|
typedef std::chrono::duration< double, std::milli > | milliseconds |
|
typedef std::chrono::duration< double, std::micro > | microseconds |
|
typedef decltype((time{} - time{}).count()) | nanoseconds |
|
typedef decltype((time{} - time{})) | duration |
|
|
time | _start = std::chrono::high_resolution_clock::now() |
|
◆ duration
◆ microseconds
◆ milliseconds
◆ nanoseconds
◆ seconds
◆ time
◆ age()
double nimble::quanta::stopwatch::age |
( |
| ) |
|
|
inline |
77 {
78 return seconds(std::chrono::high_resolution_clock::now() -
_start).count();
79 }
time _start
Definition nimble.quanta.stopwatch.h:59
std::chrono::duration< double, std::ratio< 1, 1 > > seconds
Definition nimble.quanta.stopwatch.h:54
◆ age_micro()
double nimble::quanta::stopwatch::age_micro |
( |
| ) |
|
|
inline |
67 {
69 }
std::chrono::duration< double, std::micro > microseconds
Definition nimble.quanta.stopwatch.h:56
◆ age_milli()
double nimble::quanta::stopwatch::age_milli |
( |
| ) |
|
|
inline |
72 {
74 }
std::chrono::duration< double, std::milli > milliseconds
Definition nimble.quanta.stopwatch.h:55
◆ age_nano()
62 {
63 return (std::chrono::high_resolution_clock::now() -
_start).count();
64 }
◆ get_microsecond_timestamp()
static std::string nimble::quanta::stopwatch::get_microsecond_timestamp |
( |
| ) |
|
|
inlinestatic |
120 {
121 auto epoch_duration = std::chrono::high_resolution_clock::now().time_since_epoch();
122 auto duration_in_seconds = std::chrono::duration_cast<std::chrono::seconds>(epoch_duration);
124 (std::chrono::duration_cast<std::chrono::microseconds>(epoch_duration - duration_in_seconds).count());
125 std::time_t t = duration_in_seconds.count();
126 char buffer[100]{};
127 size_t end;
128 if ((end = std::strftime(buffer, 100, "%Y.%m.%d.%H.%M.%S.", std::localtime(&t)))) {
135 buffer[end + 6] = '\0';
136 }
137 return buffer;
138 }
◆ get_millisecond_timestamp()
static std::string nimble::quanta::stopwatch::get_millisecond_timestamp |
( |
| ) |
|
|
inlinestatic |
141 {
142 auto epoch_duration = std::chrono::high_resolution_clock::now().time_since_epoch();
143 auto duration_in_seconds = std::chrono::duration_cast<std::chrono::seconds>(epoch_duration);
145 (std::chrono::duration_cast<std::chrono::milliseconds>(epoch_duration - duration_in_seconds).count());
146 std::time_t t = duration_in_seconds.count();
147 char buffer[100]{};
148 size_t end;
149 if ((end = std::strftime(buffer, 100, "%Y.%m.%e.%H.%M.%S.", std::localtime(&t)))) {
150 size_t milliseconds = (std::chrono::duration_cast<std::chrono::milliseconds>(
151 std::chrono::high_resolution_clock::now().time_since_epoch())
152 .count());
156 buffer[end + 3] = '\0';
157 }
158 return buffer;
159 }
◆ get_nanosecond_timestamp()
static std::string nimble::quanta::stopwatch::get_nanosecond_timestamp |
( |
| ) |
|
|
inlinestatic |
96 {
97 auto epoch_duration = std::chrono::high_resolution_clock::now().time_since_epoch();
98 auto duration_in_seconds = std::chrono::duration_cast<std::chrono::seconds>(epoch_duration);
100 (std::chrono::duration_cast<std::chrono::nanoseconds>(epoch_duration - duration_in_seconds).count());
101 std::time_t t = duration_in_seconds.count();
102 char buffer[100]{};
103 size_t end;
104 if ((end = std::strftime(buffer, 100, "%Y.%m.%e.%H.%M.%S.", std::localtime(&t)))) {
105 buffer[end] =
'0' + (
nanoseconds / 100000000 % 10);
106 buffer[end + 1] =
'0' + (
nanoseconds / 10000000 % 10);
107 buffer[end + 2] =
'0' + (
nanoseconds / 1000000 % 10);
108 buffer[end + 3] =
'0' + (
nanoseconds / 100000 % 10);
109 buffer[end + 4] =
'0' + (
nanoseconds / 10000 % 10);
114 buffer[end + 9] = '\0';
115 }
116 return buffer;
117 }
decltype((time{} - time{}).count()) nanoseconds
Definition nimble.quanta.stopwatch.h:57
◆ reset()
void nimble::quanta::stopwatch::reset |
( |
| ) |
|
|
inline |
82 {
83 _start = std::chrono::high_resolution_clock::now();
84 }
◆ timefunction()
template<class Function, class... Args>
static double nimble::quanta::stopwatch::timefunction |
( |
Function && | f, |
|
|
Args &&... | inputs ) |
|
inlinestatic |
88 {
89 stopwatch s;
90 s.reset();
91 f(std::forward<Args>(inputs)...);
92 return s.age();
93 }
◆ _start
time nimble::quanta::stopwatch::_start = std::chrono::high_resolution_clock::now() |
The documentation for this struct was generated from the following file: