Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1739471

[PATCH v2 2/6] perf record: Get the first sample time and last sample time

From Jin Yao <yao.jin@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v2 2/6] perf record: Get the first sample time and last sample time
Date 2017-09-26 05:10 +0200
Message-ID <utOpX-7kB-13@gated-at.bofh.it> (permalink)
References <utOpX-7kB-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


In perf record, it's walked on all samples yet. So it's very easy to get
the first/last samples and save the time to perf file header via the
function write_sample_time().

In later, perf report/script will fetch the time from perf file header.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/builtin-record.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 9b379f3..3428633 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -80,6 +80,8 @@ struct record {
 	bool			timestamp_filename;
 	struct switch_output	switch_output;
 	unsigned long long	samples;
+	u64			first_sample_time;
+	u64			last_sample_time;
 };
 
 static volatile int auxtrace_record__snapshot_started;
@@ -488,6 +490,11 @@ static int process_sample_event(struct perf_tool *tool,
 
 	rec->samples++;
 
+	if (rec->first_sample_time == 0)
+		rec->first_sample_time = sample->time;
+
+	rec->last_sample_time = sample->time;
+
 	return build_id__mark_dso_hit(tool, event, sample, evsel, machine);
 }
 
@@ -637,6 +644,14 @@ static void record__init_features(struct record *rec)
 	perf_header__clear_feat(&session->header, HEADER_STAT);
 }
 
+static void update_sample_time(struct record *rec)
+{
+	struct perf_evlist *evlist = rec->evlist;
+
+	evlist->first_sample_time = rec->first_sample_time;
+	evlist->last_sample_time = rec->last_sample_time;
+}
+
 static void
 record__finish_output(struct record *rec)
 {
@@ -655,6 +670,8 @@ record__finish_output(struct record *rec)
 		if (rec->buildid_all)
 			dsos__hit_all(rec->session);
 	}
+
+	update_sample_time(rec);
 	perf_session__write_header(rec->session, rec->evlist, fd, true);
 
 	return;
-- 
2.7.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v2 2/6] perf record: Get the first sample time and last sample time Jin Yao <yao.jin@linux.intel.com> - 2017-09-26 05:10 +0200

csiph-web