aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-timechart.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-10-01 14:20:58 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-10-02 17:36:34 -0400
commit73bdc7159b0a83146fa8d1b8df7baf1cea992d4c (patch)
treec0f58a8fc99b6f818c9edb38eaed1207837ad6da /tools/perf/builtin-timechart.c
parentc75d98afa7bb059169587b838e0a25436b8d3e62 (diff)
perf timechart: Don't use globals where not needed to
Some variables were global but used in just one function, so move it to where it belongs. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-fapdrw3h3hz713w8h5eww596@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-timechart.c')
-rw-r--r--tools/perf/builtin-timechart.c100
1 files changed, 41 insertions, 59 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index b1a8a3b841cc..f251b613b2f3 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -38,9 +38,6 @@
38#define PWR_EVENT_EXIT -1 38#define PWR_EVENT_EXIT -1
39 39
40 40
41static const char *input_name;
42static const char *output_name = "output.svg";
43
44static unsigned int numcpus; 41static unsigned int numcpus;
45static u64 min_freq; /* Lowest CPU frequency seen */ 42static u64 min_freq; /* Lowest CPU frequency seen */
46static u64 max_freq; /* Highest CPU frequency seen */ 43static u64 max_freq; /* Highest CPU frequency seen */
@@ -968,16 +965,15 @@ static void write_svg_file(const char *filename)
968 svg_close(); 965 svg_close();
969} 966}
970 967
971static struct perf_tool perf_timechart = { 968static int __cmd_timechart(const char *input_name, const char *output_name)
972 .comm = process_comm_event,
973 .fork = process_fork_event,
974 .exit = process_exit_event,
975 .sample = process_sample_event,
976 .ordered_samples = true,
977};
978
979static int __cmd_timechart(void)
980{ 969{
970 struct perf_tool perf_timechart = {
971 .comm = process_comm_event,
972 .fork = process_fork_event,
973 .exit = process_exit_event,
974 .sample = process_sample_event,
975 .ordered_samples = true,
976 };
981 struct perf_session *session = perf_session__new(input_name, O_RDONLY, 977 struct perf_session *session = perf_session__new(input_name, O_RDONLY,
982 0, false, &perf_timechart); 978 0, false, &perf_timechart);
983 int ret = -EINVAL; 979 int ret = -EINVAL;
@@ -1005,40 +1001,25 @@ out_delete:
1005 return ret; 1001 return ret;
1006} 1002}
1007 1003
1008static const char * const timechart_usage[] = {
1009 "perf timechart [<options>] {record}",
1010 NULL
1011};
1012
1013#ifdef SUPPORT_OLD_POWER_EVENTS
1014static const char * const record_old_args[] = {
1015 "record",
1016 "-a",
1017 "-R",
1018 "-f",
1019 "-c", "1",
1020 "-e", "power:power_start",
1021 "-e", "power:power_end",
1022 "-e", "power:power_frequency",
1023 "-e", "sched:sched_wakeup",
1024 "-e", "sched:sched_switch",
1025};
1026#endif
1027
1028static const char * const record_new_args[] = {
1029 "record",
1030 "-a",
1031 "-R",
1032 "-f",
1033 "-c", "1",
1034 "-e", "power:cpu_frequency",
1035 "-e", "power:cpu_idle",
1036 "-e", "sched:sched_wakeup",
1037 "-e", "sched:sched_switch",
1038};
1039
1040static int __cmd_record(int argc, const char **argv) 1004static int __cmd_record(int argc, const char **argv)
1041{ 1005{
1006#ifdef SUPPORT_OLD_POWER_EVENTS
1007 const char * const record_old_args[] = {
1008 "record", "-a", "-R", "-f", "-c", "1",
1009 "-e", "power:power_start",
1010 "-e", "power:power_end",
1011 "-e", "power:power_frequency",
1012 "-e", "sched:sched_wakeup",
1013 "-e", "sched:sched_switch",
1014 };
1015#endif
1016 const char * const record_new_args[] = {
1017 "record", "-a", "-R", "-f", "-c", "1",
1018 "-e", "power:cpu_frequency",
1019 "-e", "power:cpu_idle",
1020 "-e", "sched:sched_wakeup",
1021 "-e", "sched:sched_switch",
1022 };
1042 unsigned int rec_argc, i, j; 1023 unsigned int rec_argc, i, j;
1043 const char **rec_argv; 1024 const char **rec_argv;
1044 const char * const *record_args = record_new_args; 1025 const char * const *record_args = record_new_args;
@@ -1077,27 +1058,28 @@ parse_process(const struct option *opt __maybe_unused, const char *arg,
1077 return 0; 1058 return 0;
1078} 1059}
1079 1060
1080static const struct option options[] = { 1061int cmd_timechart(int argc, const char **argv,
1081 OPT_STRING('i', "input", &input_name, "file", 1062 const char *prefix __maybe_unused)
1082 "input file name"), 1063{
1083 OPT_STRING('o', "output", &output_name, "file", 1064 const char *input_name;
1084 "output file name"), 1065 const char *output_name = "output.svg";
1085 OPT_INTEGER('w', "width", &svg_page_width, 1066 const struct option options[] = {
1086 "page width"), 1067 OPT_STRING('i', "input", &input_name, "file", "input file name"),
1087 OPT_BOOLEAN('P', "power-only", &power_only, 1068 OPT_STRING('o', "output", &output_name, "file", "output file name"),
1088 "output power data only"), 1069 OPT_INTEGER('w', "width", &svg_page_width, "page width"),
1070 OPT_BOOLEAN('P', "power-only", &power_only, "output power data only"),
1089 OPT_CALLBACK('p', "process", NULL, "process", 1071 OPT_CALLBACK('p', "process", NULL, "process",
1090 "process selector. Pass a pid or process name.", 1072 "process selector. Pass a pid or process name.",
1091 parse_process), 1073 parse_process),
1092 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", 1074 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
1093 "Look for files with symbols relative to this directory"), 1075 "Look for files with symbols relative to this directory"),
1094 OPT_END() 1076 OPT_END()
1095}; 1077 };
1096 1078 const char * const timechart_usage[] = {
1079 "perf timechart [<options>] {record}",
1080 NULL
1081 };
1097 1082
1098int cmd_timechart(int argc, const char **argv,
1099 const char *prefix __maybe_unused)
1100{
1101 argc = parse_options(argc, argv, options, timechart_usage, 1083 argc = parse_options(argc, argv, options, timechart_usage,
1102 PARSE_OPT_STOP_AT_NON_OPTION); 1084 PARSE_OPT_STOP_AT_NON_OPTION);
1103 1085
@@ -1110,5 +1092,5 @@ int cmd_timechart(int argc, const char **argv,
1110 1092
1111 setup_pager(); 1093 setup_pager();
1112 1094
1113 return __cmd_timechart(); 1095 return __cmd_timechart(input_name, output_name);
1114} 1096}