From: Andy Spencer Date: Sat, 15 Mar 2014 21:58:11 +0000 (+0000) Subject: Add heuristics for time printing X-Git-Url: http://pileus.org/git/?p=~andy%2Fcsm213a-hw;a=commitdiff_plain;h=7a471237f204bb160a09092e9787a294f28d6c8c Add heuristics for time printing --- diff --git a/hw2/main_time.c b/hw2/main_time.c index e022c6a..120054c 100644 --- a/hw2/main_time.c +++ b/hw2/main_time.c @@ -91,11 +91,18 @@ void time_ext_sync(uint64_t local, uint64_t world) void time_printf(const char *label, uint64_t local) { - uint64_t world = time_to_world(local); - sirq_printf("%s -- %d.%09u -> %d.%09u\r\n", - label, - (int)(local / NSEC_PER_SEC), - (int)(local % NSEC_PER_SEC), - (int)(world / NSEC_PER_SEC), - (int)(world % NSEC_PER_SEC)); + if (local > 1000000 * NSEC_PER_SEC) { + sirq_printf("%s -- %14s -> %d.%09u\r\n", + label, "", + (int)(local / NSEC_PER_SEC), + (int)(local % NSEC_PER_SEC)); + } else { + uint64_t world = time_to_world(local); + sirq_printf("%s -- %4d.%09u -> %d.%09u\r\n", + label, + (int)(local / NSEC_PER_SEC), + (int)(local % NSEC_PER_SEC), + (int)(world / NSEC_PER_SEC), + (int)(world % NSEC_PER_SEC)); + } }