]> Pileus Git - ~andy/csm213a-hw/commitdiff
Add heuristics for time printing
authorAndy Spencer <andy753421@gmail.com>
Sat, 15 Mar 2014 21:58:11 +0000 (21:58 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 15 Mar 2014 22:07:11 +0000 (22:07 +0000)
hw2/main_time.c

index e022c6aac75534ed0d62e4a80b5fb849cbd67bde..120054c950a07f6c8b2e8f0e8060c312c3e52d30 100644 (file)
@@ -91,11 +91,18 @@ void time_ext_sync(uint64_t local, uint64_t world)
 
 void time_printf(const char *label, uint64_t local)
 {
 
 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));
+       }
 }
 }