82 start_ = clock_type::now();
88 const auto now = clock_type::now();
89 const std::chrono::duration<double> d = now -
start_;
114 std::forward<F>(f)();
128 thread_local char buf[64];
129 if (
const double abs_rate = cells_per_second < 0 ? -cells_per_second : cells_per_second;
131 std::snprintf(buf,
sizeof(buf),
"%6.2f G cells/s", cells_per_second / 1e9);
132 else if (abs_rate >= 1e6)
133 std::snprintf(buf,
sizeof(buf),
"%6.2f M cells/s", cells_per_second / 1e6);
134 else if (abs_rate >= 1e3)
135 std::snprintf(buf,
sizeof(buf),
"%6.2f K cells/s", cells_per_second / 1e3);
137 std::snprintf(buf,
sizeof(buf),
"%6.2f cells/s", cells_per_second);
Tiny start/stop wall-clock timer.
double elapsed_seconds() const noexcept
void restart() noexcept
Restart the timer to now().
clock_type::time_point time_point
double elapsed_milliseconds() const noexcept
std::chrono::steady_clock clock_type
const char * format_throughput(double cells_per_second)
Format a "cells per second" rate as "X.XX M cells/s".
double bench_seconds(F &&f)
Run f() once and return the wall-clock time it took, in seconds.
Main namespace for Aleph-w library functions.