Add function for getting the timestamp in nanoseconds
authorMichele Tartara <mtartara@google.com>
Mon, 25 Mar 2013 14:21:06 +0000 (15:21 +0100)
committerMichele Tartara <mtartara@google.com>
Mon, 22 Apr 2013 11:11:18 +0000 (11:11 +0000)
The timestamp is returned as an integer number of nanoseconds since the Unix
epoch.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

lib/utils/__init__.py

index cda87f4..f9468fc 100644 (file)
@@ -525,6 +525,16 @@ def MergeTime(timetuple):
   return float(seconds) + (float(microseconds) * 0.000001)
 
 
+def EpochNano():
+  """Return the current timestamp expressed as number of nanoseconds since the
+  unix epoch
+
+  @return: nanoseconds since the Unix epoch
+
+  """
+  return int(time.time() * 1000000000)
+
+
 def FindMatch(data, name):
   """Tries to find an item in a dictionary matching a name.