time: add a convenience function, nsec()
authorRonald G. Minnich <rminnich@google.com>
Wed, 14 May 2014 01:11:13 +0000 (18:11 -0700)
committerRonald G. Minnich <rminnich@google.com>
Wed, 14 May 2014 01:12:07 +0000 (18:12 -0700)
Simple inline, but it's handy.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
kern/include/time.h

index 92ee9b4..0fb40cc 100644 (file)
@@ -57,6 +57,13 @@ uint64_t stop_timing(uint64_t start_time)
        return diff;
 }
 
+static inline __attribute__((always_inline))
+uint64_t nsec(void)
+{
+       return tsc2nsec(read_tsc());
+}
+
+
 /* Ancient measurement crap below.  TODO: use or lose it */
 
 #if 0