diff options
author | Jiri Olsa <jolsa@kernel.org> | 2018-06-06 18:15:06 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-06-07 14:53:36 -0400 |
commit | 9660e08ee8cbc94ac835f2c30576c6e51fbece8f (patch) | |
tree | 8da527880d0bb8c7ff1029227e7632e23291b503 /tools/perf | |
parent | f7fa827f5f432a0b1f34e10fc49da93aeef9f817 (diff) |
perf stat: Add --interval-clear option
Adding --interval-clear option to clear the screen before next interval.
Committer testing:
# perf stat -I 1000 --interval-clear
And, as expected, it behaves almost like:
# watch -n 0 perf stat -a sleep 1
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20180606221513.11302-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/Documentation/perf-stat.txt | 3 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index 5dfe102fb5b5..b10a90b6a718 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt | |||
@@ -178,6 +178,9 @@ Print count deltas for fixed number of times. | |||
178 | This option should be used together with "-I" option. | 178 | This option should be used together with "-I" option. |
179 | example: 'perf stat -I 1000 --interval-count 2 -e cycles -a' | 179 | example: 'perf stat -I 1000 --interval-count 2 -e cycles -a' |
180 | 180 | ||
181 | --interval-clear:: | ||
182 | Clear the screen before next interval. | ||
183 | |||
181 | --timeout msecs:: | 184 | --timeout msecs:: |
182 | Stop the 'perf stat' session and print count deltas after N milliseconds (minimum: 10 ms). | 185 | Stop the 'perf stat' session and print count deltas after N milliseconds (minimum: 10 ms). |
183 | This option is not supported with the "-I" option. | 186 | This option is not supported with the "-I" option. |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 096ccb25c11f..f1532e3ac7d7 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -65,6 +65,7 @@ | |||
65 | #include "util/tool.h" | 65 | #include "util/tool.h" |
66 | #include "util/string2.h" | 66 | #include "util/string2.h" |
67 | #include "util/metricgroup.h" | 67 | #include "util/metricgroup.h" |
68 | #include "util/top.h" | ||
68 | #include "asm/bug.h" | 69 | #include "asm/bug.h" |
69 | 70 | ||
70 | #include <linux/time64.h> | 71 | #include <linux/time64.h> |
@@ -173,6 +174,7 @@ static struct cpu_map *aggr_map; | |||
173 | static aggr_get_id_t aggr_get_id; | 174 | static aggr_get_id_t aggr_get_id; |
174 | static bool append_file; | 175 | static bool append_file; |
175 | static bool interval_count; | 176 | static bool interval_count; |
177 | static bool interval_clear; | ||
176 | static const char *output_name; | 178 | static const char *output_name; |
177 | static int output_fd; | 179 | static int output_fd; |
178 | static int print_free_counters_hint; | 180 | static int print_free_counters_hint; |
@@ -1704,9 +1706,12 @@ static void print_interval(char *prefix, struct timespec *ts) | |||
1704 | FILE *output = stat_config.output; | 1706 | FILE *output = stat_config.output; |
1705 | static int num_print_interval; | 1707 | static int num_print_interval; |
1706 | 1708 | ||
1709 | if (interval_clear) | ||
1710 | puts(CONSOLE_CLEAR); | ||
1711 | |||
1707 | sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep); | 1712 | sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep); |
1708 | 1713 | ||
1709 | if (num_print_interval == 0 && !csv_output) { | 1714 | if ((num_print_interval == 0 && !csv_output) || interval_clear) { |
1710 | switch (stat_config.aggr_mode) { | 1715 | switch (stat_config.aggr_mode) { |
1711 | case AGGR_SOCKET: | 1716 | case AGGR_SOCKET: |
1712 | fprintf(output, "# time socket cpus"); | 1717 | fprintf(output, "# time socket cpus"); |
@@ -1738,7 +1743,7 @@ static void print_interval(char *prefix, struct timespec *ts) | |||
1738 | } | 1743 | } |
1739 | } | 1744 | } |
1740 | 1745 | ||
1741 | if (num_print_interval == 0 && metric_only) | 1746 | if ((num_print_interval == 0 && metric_only) || interval_clear) |
1742 | print_metric_headers(" ", true); | 1747 | print_metric_headers(" ", true); |
1743 | if (++num_print_interval == 25) | 1748 | if (++num_print_interval == 25) |
1744 | num_print_interval = 0; | 1749 | num_print_interval = 0; |
@@ -2057,6 +2062,8 @@ static const struct option stat_options[] = { | |||
2057 | "(overhead is possible for values <= 100ms)"), | 2062 | "(overhead is possible for values <= 100ms)"), |
2058 | OPT_INTEGER(0, "interval-count", &stat_config.times, | 2063 | OPT_INTEGER(0, "interval-count", &stat_config.times, |
2059 | "print counts for fixed number of times"), | 2064 | "print counts for fixed number of times"), |
2065 | OPT_BOOLEAN(0, "interval-clear", &interval_clear, | ||
2066 | "clear screen in between new interval"), | ||
2060 | OPT_UINTEGER(0, "timeout", &stat_config.timeout, | 2067 | OPT_UINTEGER(0, "timeout", &stat_config.timeout, |
2061 | "stop workload and print counts after a timeout period in ms (>= 10ms)"), | 2068 | "stop workload and print counts after a timeout period in ms (>= 10ms)"), |
2062 | OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode, | 2069 | OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode, |