]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
perf time-utils: Add utility function to print time stamps in nanoseconds
authorAndi Kleen <ak@linux.intel.com>
Tue, 5 Mar 2019 14:47:53 +0000 (06:47 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 11 Mar 2019 14:56:02 +0000 (11:56 -0300)
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>
tools/perf/util/time-utils.c
tools/perf/util/time-utils.h

index 0f53baec660e2494db6f3e506ddff91c05d89c36..20663a460df34d63d9d575ebea8a7e7681099bc7 100644 (file)
@@ -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;
index b923de44e36f9b350c9b94c021ccee732bc5f7df..72a42ea1d513af55f54896da02ce66bc6d037a82 100644 (file)
@@ -30,6 +30,7 @@ int perf_time__parse_for_ranges(const char *str, struct perf_session *session,
                                int *range_size, int *range_num);
 
 int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz);
+int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz);
 
 int fetch_current_timestamp(char *buf, size_t sz);