diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-04-04 02:56:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-04-04 02:56:56 +0200 |
commit | 2fa4092c2829dd14e50c430ae2f23551d23c6c1d (patch) | |
tree | acc0b56b0f7f1f93afde6a0feb8f38c332236352 /src/core/manager.c | |
parent | 911963f1a29897eee2fffbe503ac05ec13028a30 (diff) |
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.
Diffstat (limited to 'src/core/manager.c')
-rw-r--r-- | src/core/manager.c | 18 |
1 files changed, 9 insertions, 9 deletions
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) { |