From 7a471237f204bb160a09092e9787a294f28d6c8c Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sat, 15 Mar 2014 21:58:11 +0000 Subject: [PATCH] Add heuristics for time printing --- hw2/main_time.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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)); + } } -- 2.43.2