1#include <sys/resource.h>
2#include "Stopwatch.h"
3
4StopwatchRUsage::Timestamp StopwatchRUsage::Timestamp::current()
5{
6 StopwatchRUsage::Timestamp res;
7
8 ::rusage rusage {};
9#if !defined(__APPLE__)
10 ::getrusage(RUSAGE_THREAD, &rusage);
11#endif
12 res.user_ns = rusage.ru_utime.tv_sec * 1000000000UL + rusage.ru_utime.tv_usec * 1000UL;
13 res.sys_ns = rusage.ru_stime.tv_sec * 1000000000UL + rusage.ru_stime.tv_usec * 1000UL;
14 return res;
15}
16