/** * @brief Format a time duration to a human-readable string. * * @param seconds the duration in seconds. * @return std::string the formatted string. */ std::string fmt_timeduration_s(uint64_t seconds); /** * @brief Format a time duration to a human-readable string. * * @param microseconds the duration in microseconds. * @return std::string the formatted string. */ std::string fmt_timeduration_ms(uint64_t microseconds); /** * @brief Format a time duration to a human-readable string. * * @param nanoseconds the duration in nanoseconds. * @return std::string the formatted string. */ std::string fmt_timeduration_us(uint64_t nanoseconds);
std::string fmt_timeduration_ms(uint64_t microseconds) { auto s = microseconds / THOUSAND; auto ms = microseconds % THOUSAND; auto text = fmt_timeduration_s(s); text += "." + fmt_uint(ms, 3) + "ms"; return text; }
std::string fmt_timeduration_us(uint64_t nanoseconds) { auto s = nanoseconds / MILLION; auto ms = nanoseconds % MILLION; auto text = fmt_timeduration_s(s); text += "." + fmt_uint(ms, 6) + "us"; return text; }