lkml.org 
[lkml]   [2017]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 2/6] perf record: Get the first sample time and last sample time
Date
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
\
 
 \ /
  Last update: 2017-09-26 05:04    [W:0.076 / U:1.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site