summaryrefslogtreecommitdiff
path: root/tools/perf/util/time-utils.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2019-03-05 06:47:53 -0800
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-03-11 11:56:02 -0300
commitf8c856cb2c947f4fad0a2dff5e95cdcddb801303 (patch)
tree92940115a785364920289795783f92ce54f7faf1 /tools/perf/util/time-utils.c
parent52bab8868211b7c504146f6239e101421d4d125b (diff)
perf time-utils: Add utility function to print time stamps in nanoseconds
Add a utility function to print nanosecond timestamps. Signed-off-by: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20190305144758.12397-11-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/time-utils.c')
-rw-r--r--tools/perf/util/time-utils.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c
index 0f53baec660e..20663a460df3 100644
--- a/tools/perf/util/time-utils.c
+++ b/tools/perf/util/time-utils.c
@@ -453,6 +453,14 @@ int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz)
return scnprintf(buf, sz, "%"PRIu64".%06"PRIu64, sec, usec);
}
+int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz)
+{
+ u64 sec = timestamp / NSEC_PER_SEC,
+ nsec = timestamp % NSEC_PER_SEC;
+
+ return scnprintf(buf, sz, "%" PRIu64 ".%09" PRIu64, sec, nsec);
+}
+
int fetch_current_timestamp(char *buf, size_t sz)
{
struct timeval tv;