25#ifndef DOXYGEN_SHOULD_SKIP_THIS
27#ifndef UTILS_OS_WINDOWS
62#ifdef UTILS_OS_WINDOWS
65 using real_type = double;
66 int64_t m_frequency{0};
67 int64_t m_t1{0}, m_t2{0};
68 real_type m_elapsed_time{0};
104 real_type
elapsed_s()
const {
return 1e-3*m_elapsed_time; }
111 real_type
elapsed_ms()
const {
return m_elapsed_time; }
118 real_type
elapsed_mus()
const {
return 1000*m_elapsed_time; }
125 real_type
elapsed_ns()
const {
return 1e6*m_elapsed_time; }
172 using real_type = double;
173 using clock = std::chrono::high_resolution_clock;
174 using elapsed_resolution = std::chrono::microseconds;
176 clock::time_point m_start_time;
177 clock::time_point m_stop_time;
179 elapsed_resolution m_elapsed_time{0};
203 { m_start_time = clock::now(); }
213 m_stop_time = clock::now();
214 m_elapsed_time = std::chrono::duration_cast<elapsed_resolution>(m_stop_time - m_start_time);
222 real_type
elapsed_s()
const {
return real_type(1e-6*m_elapsed_time.count()); }
229 real_type
elapsed_ms()
const {
return real_type(1e-3*m_elapsed_time.count()); }
236 real_type
elapsed_mus()
const {
return real_type(m_elapsed_time.count()); }
243 real_type
elapsed_ns()
const {
return real_type(1e3*m_elapsed_time.count()); }
257 { std::this_thread::sleep_for(std::chrono::seconds(s)); }
270 { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); }
283 { std::this_thread::sleep_for(std::chrono::microseconds(mus)); }
296 { std::this_thread::sleep_for(std::chrono::nanoseconds(ns)); }
A class for timing code execution.
Definition TicToc.hxx:170
TicToc const & operator=(TicToc const &) const =delete
void tic()
Start timing.
Definition TicToc.hxx:202
void toc()
End timing.
Definition TicToc.hxx:212
real_type elapsed_ms() const
Return elapsed time (between tic-toc) in milliseconds.
Definition TicToc.hxx:229
TicToc()
Constructs a TicToc object and starts the timer.
Definition TicToc.hxx:192
real_type elapsed_s() const
Return elapsed time (between tic-toc) in seconds.
Definition TicToc.hxx:222
real_type elapsed_ns() const
Return elapsed time (between tic-toc) in nanoseconds.
Definition TicToc.hxx:243
TicToc(TicToc const &)=delete
real_type elapsed_mus() const
Return elapsed time (between tic-toc) in microseconds.
Definition TicToc.hxx:236
Definition SystemUtils.cc:39
void sleep_for_milliseconds(unsigned ms)
Sleep for a specified number of milliseconds.
Definition TicToc.hxx:269
void sleep_for_seconds(unsigned s)
Sleep for a specified number of seconds.
Definition TicToc.hxx:256
void sleep_for_nanoseconds(unsigned ns)
Sleep for a specified number of nanoseconds.
Definition TicToc.hxx:295
void sleep_for_microseconds(unsigned mus)
Sleep for a specified number of microseconds.
Definition TicToc.hxx:282