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/core/manager.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/core/manager.c') diff --git a/src/core/manager.c b/src/core/manager.c index 2e89f19839..f90ccd5b5f 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2415,10 +2415,10 @@ void manager_check_finished(Manager *m) { "INITRD_USEC=%llu", (unsigned long long) initrd_usec, "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec, "MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.", - format_timespan(kernel, sizeof(kernel), kernel_usec), - format_timespan(initrd, sizeof(initrd), initrd_usec), - format_timespan(userspace, sizeof(userspace), userspace_usec), - format_timespan(sum, sizeof(sum), total_usec), + format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC), + format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC), + format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC), + format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC), NULL); } else { kernel_usec = m->userspace_timestamp.monotonic - m->kernel_timestamp.monotonic; @@ -2430,9 +2430,9 @@ void manager_check_finished(Manager *m) { "KERNEL_USEC=%llu", (unsigned long long) kernel_usec, "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec, "MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.", - format_timespan(kernel, sizeof(kernel), kernel_usec), - format_timespan(userspace, sizeof(userspace), userspace_usec), - format_timespan(sum, sizeof(sum), total_usec), + format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC), + format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC), + format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC), NULL); } } else { @@ -2444,7 +2444,7 @@ void manager_check_finished(Manager *m) { MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED), "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec, "MESSAGE=Startup finished in %s.", - format_timespan(sum, sizeof(sum), total_usec), + format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC), NULL); } @@ -2452,7 +2452,7 @@ void manager_check_finished(Manager *m) { sd_notifyf(false, "READY=1\nSTATUS=Startup finished in %s.", - format_timespan(sum, sizeof(sum), total_usec)); + format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)); } static int create_generator_dir(Manager *m, char **generator, const char *name) { -- cgit v1.2.3-54-g00ecf