From c28911ddf8d75f3473a4f15f3b6e68a792502c8b Mon Sep 17 00:00:00 2001 From: Michele Tartara <mtartara@google.com> Date: Mon, 25 Mar 2013 15:21:06 +0100 Subject: [PATCH] Add function for getting the timestamp in nanoseconds 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/utils/__init__.py b/lib/utils/__init__.py index cda87f454..f9468fc37 100644 --- a/lib/utils/__init__.py +++ b/lib/utils/__init__.py @@ -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. -- GitLab