aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-timechart.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-11 18:24:02 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-12 01:42:12 -0500
commit94c744b6c0c6c5802a85ebfebbec429ac5851f2b (patch)
treee34dcaca54f1d7752ab1e7974bb73f94ff3cf94c /tools/perf/builtin-timechart.c
parentea08d8cbd162fe3756e3e2298efbe0b8b12f92d1 (diff)
perf tools: Introduce perf_session class
That does all the initialization boilerplate, opening the file, reading the header, checking if it is valid, etc. And that will as well have the threads list, kmap (now) global variable, etc, so that we can handle two (or more) perf.data files describing sessions to compare. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1260573842-19720-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-timechart.c')
-rw-r--r--tools/perf/builtin-timechart.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index f472df9561ee..759dd2b35fdb 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1059,15 +1059,17 @@ static struct perf_file_handler file_handler = {
1059 1059
1060static int __cmd_timechart(void) 1060static int __cmd_timechart(void)
1061{ 1061{
1062 struct perf_header *header; 1062 struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
1063 int ret; 1063 int ret;
1064 1064
1065 if (session == NULL)
1066 return -ENOMEM;
1067
1065 register_perf_file_handler(&file_handler); 1068 register_perf_file_handler(&file_handler);
1066 1069
1067 ret = mmap_dispatch_perf_file(&header, input_name, 0, 0, 1070 ret = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
1068 &event__cwdlen, &event__cwd);
1069 if (ret) 1071 if (ret)
1070 return EXIT_FAILURE; 1072 goto out_delete;
1071 1073
1072 process_samples(); 1074 process_samples();
1073 1075
@@ -1079,8 +1081,9 @@ static int __cmd_timechart(void)
1079 1081
1080 pr_info("Written %2.1f seconds of trace to %s.\n", 1082 pr_info("Written %2.1f seconds of trace to %s.\n",
1081 (last_time - first_time) / 1000000000.0, output_name); 1083 (last_time - first_time) / 1000000000.0, output_name);
1082 1084out_delete:
1083 return EXIT_SUCCESS; 1085 perf_session__delete(session);
1086 return ret;
1084} 1087}
1085 1088
1086static const char * const timechart_usage[] = { 1089static const char * const timechart_usage[] = {