[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190226030412.23485-10-andi@firstfloor.org>
Date: Mon, 25 Feb 2019 19:04:10 -0800
From: Andi Kleen <andi@...stfloor.org>
To: acme@...nel.org
Cc: jolsa@...nel.org, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, eranian@...gle.com,
Andi Kleen <ak@...ux.intel.com>
Subject: [PATCH v2 09/11] perf tools: Add utility function to print ns time stamps
From: Andi Kleen <ak@...ux.intel.com>
Add a utility function to print nanosecond timestamps.
Signed-off-by: Andi Kleen <ak@...ux.intel.com>
---
tools/perf/util/time-utils.c | 8 ++++++++
tools/perf/util/time-utils.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c
index 6193b46050a5..a63bdf4cfd1b 100644
--- a/tools/perf/util/time-utils.c
+++ b/tools/perf/util/time-utils.c
@@ -404,6 +404,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;
+ u64 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;
diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h
index 70b177d2b98c..9266cf4a8e58 100644
--- a/tools/perf/util/time-utils.h
+++ b/tools/perf/util/time-utils.h
@@ -24,6 +24,7 @@ bool perf_time__ranges_skip_sample(struct perf_time_interval *ptime_buf,
int num, u64 timestamp);
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);
--
2.17.2
Powered by blists - more mailing lists