0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-02 13:48:53 +02:00

ircd::util: Add microtime() util.

This commit is contained in:
Jason Volk 2016-08-25 20:43:53 -07:00
parent 4e8fd35341
commit e586d268fc

View file

@ -215,6 +215,23 @@ size(std::ostream &s)
}
inline std::pair<time_t, int32_t>
microtime()
{
struct timeval tv;
gettimeofday(&tv, nullptr);
return { tv.tv_sec, tv.tv_usec };
}
inline ssize_t
microtime(char *const &buf,
const size_t &size)
{
const auto mt(microtime());
return snprintf(buf, size, "%zd.%06d", mt.first, mt.second);
}
} // namespace util
} // namespace ircd
#endif // __cplusplus