Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1263298
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 11/25] perf stat report: Add report command |
| Date | 2015-11-05 16:00 +0100 |
| Message-ID | <qrub7-81X-1@gated-at.bofh.it> (permalink) |
| References | <qru1r-7Yg-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Adding 'perf stat report' command support. ATM it only
processes attr events and display nothing.
Tested-by: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/n/tip-a43rs4c6szofeuo2gjlcpm0h@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/Documentation/perf-stat.txt | 12 +++++++
tools/perf/builtin-stat.c | 61 +++++++++++++++++++++++++++++++---
2 files changed, 69 insertions(+), 4 deletions(-)
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 70eee1c2c444..95f492828657 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -11,6 +11,7 @@ SYNOPSIS
'perf stat' [-e <EVENT> | --event=EVENT] [-a] <command>
'perf stat' [-e <EVENT> | --event=EVENT] [-a] -- <command> [<options>]
'perf stat' [-e <EVENT> | --event=EVENT] [-a] record [-o file] -- <command> [<options>]
+'perf stat' report [-i file]
DESCRIPTION
-----------
@@ -26,6 +27,9 @@ OPTIONS
record::
See STAT RECORD.
+report::
+ See STAT REPORT.
+
-e::
--event=::
Select the PMU event. Selection can be:
@@ -170,6 +174,14 @@ Stores stat data into perf data file.
--output file::
Output file name.
+STAT REPORT
+-----------
+Reads and reports stat data from perf data file.
+
+-i file::
+--input file::
+Input file name.
+
EXAMPLES
--------
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 5d34544e3079..e921ad542846 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -60,6 +60,8 @@
#include "util/thread_map.h"
#include "util/counts.h"
#include "util/session.h"
+#include "util/tool.h"
+#include "asm/bug.h"
#include <stdlib.h>
#include <sys/prctl.h>
@@ -132,6 +134,7 @@ struct perf_stat {
struct perf_data_file file;
struct perf_session *session;
u64 bytes_written;
+ struct perf_tool tool;
};
static struct perf_stat perf_stat;
@@ -1020,8 +1023,8 @@ static void print_header(int argc, const char **argv)
else if (target.cpu_list)
fprintf(output, "\'CPU(s) %s", target.cpu_list);
else if (!target__has_task(&target)) {
- fprintf(output, "\'%s", argv[0]);
- for (i = 1; i < argc; i++)
+ fprintf(output, "\'%s", argv ? argv[0] : "pipe");
+ for (i = 1; argv && (i < argc); i++)
fprintf(output, " %s", argv[i]);
} else if (target.pid)
fprintf(output, "process id \'%s", target.pid);
@@ -1498,6 +1501,55 @@ static int __cmd_record(int argc, const char **argv)
return argc;
}
+static const char * const report_usage[] = {
+ "perf stat report [<options>]",
+ NULL,
+};
+
+static struct perf_stat perf_stat = {
+ .tool = {
+ .attr = perf_event__process_attr,
+ },
+};
+
+static int __cmd_report(int argc, const char **argv)
+{
+ struct perf_session *session;
+ const struct option options[] = {
+ OPT_STRING('i', "input", &input_name, "file", "input file name"),
+ OPT_END()
+ };
+ struct stat st;
+ int ret;
+
+ argc = parse_options(argc, argv, options, report_usage, 0);
+
+ if (!input_name || !strlen(input_name)) {
+ if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
+ input_name = "-";
+ else
+ input_name = "perf.data";
+ }
+
+ perf_stat.file.path = input_name;
+ perf_stat.file.mode = PERF_DATA_MODE_READ;
+
+ session = perf_session__new(&perf_stat.file, false, &perf_stat.tool);
+ if (session == NULL)
+ return -1;
+
+ perf_stat.session = session;
+ stat_config.output = stderr;
+ evsel_list = session->evlist;
+
+ ret = perf_session__process_events(session);
+ if (ret)
+ return ret;
+
+ perf_session__delete(session);
+ return 0;
+}
+
int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
{
const char * const stat_usage[] = {
@@ -1508,7 +1560,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
const char *mode;
FILE *output = stderr;
unsigned int interval;
- const char * const stat_subcommands[] = { "record" };
+ const char * const stat_subcommands[] = { "record", "report" };
setlocale(LC_ALL, "");
@@ -1524,7 +1576,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
argc = __cmd_record(argc, argv);
if (argc < 0)
return -1;
- }
+ } else if (argc && !strncmp(argv[0], "rep", 3))
+ return __cmd_report(argc, argv);
interval = stat_config.interval;
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCHv6 00/25] perf stat: Add scripting support Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
[PATCH 15/25] perf stat report: Process stat and stat round events Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
[PATCH 14/25] perf stat report: Add support to initialize aggr_map from file Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
[PATCH 24/25] perf script: Add python support for stat events Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
[PATCH 11/25] perf stat report: Add report command Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 16/25] perf stat report: Process event update events Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 08/25] perf stat record: Write stat round events on record Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 12/25] perf stat report: Process cpu/threads maps Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 20/25] perf script: Process stat config event Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 01/25] perf stat: Make stat options global Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[tip:perf/urgent] perf stat: Make stat options global tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-08 08:40 +0100
[PATCH 03/25] perf stat record: Initialize record features Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 18/25] perf stat report: Allow to override aggr_mode Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
csiph-web