Updating command "time" to report wall time.

This commit is contained in:
Alan Mishchenko 2023-09-09 10:06:33 +07:00
parent a4755a37cb
commit 6d866dab6b
1 changed files with 8 additions and 0 deletions

View File

@ -394,9 +394,17 @@ ABC_NAMESPACE_IMPL_START
double Extra_CpuTimeDouble()
{
/*
struct rusage ru;
getrusage(RUSAGE_SELF, &ru);
return (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000;
*/
struct timespec ts;
if ( clock_gettime(CLOCK_MONOTONIC, &ts) < 0 )
return (double)-1;
double res = ((double) ts.tv_sec);
res += ((double) ts.tv_nsec) / 1000000000;
return res;
}
#endif