From 2fa4092c2829dd14e50c430ae2f23551d23c6c1d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 4 Apr 2013 02:56:56 +0200 Subject: util: make time formatting a bit smarter Instead of outputting "5h 55s 50ms 3us" we'll now output "5h 55.050003s". Also, while outputting the accuracy is configurable. Basically we now try use "dot notation" for all time values > 1min. For >= 1s we use 's' as unit, otherwise for >= 1ms we use 'ms' as unit, and finally 'us'. This should give reasonably values in most cases. --- src/cgtop/cgtop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cgtop') diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index 280470dbd0..1c05e6049c 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -803,7 +803,7 @@ int main(int argc, char *argv[]) { else arg_delay += USEC_PER_SEC; - fprintf(stdout, "\nIncreased delay to %s.", format_timespan(h, sizeof(h), arg_delay)); + fprintf(stdout, "\nIncreased delay to %s.", format_timespan(h, sizeof(h), arg_delay, 0)); fflush(stdout); sleep(1); break; @@ -816,7 +816,7 @@ int main(int argc, char *argv[]) { else arg_delay -= USEC_PER_SEC; - fprintf(stdout, "\nDecreased delay to %s.", format_timespan(h, sizeof(h), arg_delay)); + fprintf(stdout, "\nDecreased delay to %s.", format_timespan(h, sizeof(h), arg_delay, 0)); fflush(stdout); sleep(1); break; -- cgit v1.2.3-54-g00ecf