[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CPU usage truncated output
From: |
Philip Rowlands |
Subject: |
CPU usage truncated output |
Date: |
Fri, 30 Oct 2020 22:14:31 +0000 |
User-agent: |
Cyrus-JMAP/3.3.0-530-g8da6958-fm-20201021.003-g69105b13-v35 |
Is there any way to ask time for greater than 2 decimal points of precision?
I see in time.c that the formats for %U / %S / %E are fixed, e.g.
fprintf (fp, "%ld.%02ld",
(long int)(resp->ru.ru_utime.tv_sec),
(long int)(resp->ru.ru_utime.TV_MSEC / 10));
It's a toy example, but consider the output of the following command, where
/bin/true takes 0.015625 seconds of user time, but time truncates the output to
"0.01user".
I'm not suggesting changing the default, but perhaps extending the format
syntax to allow for extra precision.
Cheers,
Phil
$ strace -v -e wait4 time /bin/true
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0,
{ru_utime={tv_sec=0, tv_usec=15625},
ru_stime={tv_sec=0, tv_usec=0},
ru_maxrss=472,
ru_ixrss=0,
ru_idrss=0,
ru_isrss=0,
ru_minflt=146,
ru_majflt=0,
ru_nswap=0,
ru_inblock=0,
ru_oublock=0,
ru_msgsnd=0,
ru_msgrcv=0,
ru_nsignals=0,
ru_nvcsw=0,
ru_nivcsw=0}) = 168
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=168, si_uid=1000,
si_status=0, si_utime=0, si_stime=0} ---
0.01user 0.00system 0:00.01elapsed 125%CPU (0avgtext+0avgdata 472maxresident)k
0inputs+0outputs (0major+146minor)pagefaults 0swaps
+++ exited with 0 +++
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- CPU usage truncated output,
Philip Rowlands <=