Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1302215

[PATCH 6/8] perf script: Display stat events by default

From Jiri Olsa <jolsa@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 6/8] perf script: Display stat events by default
Date 2016-01-05 22:20 +0100
Message-ID <qNHbl-8sH-31@gated-at.bofh.it> (permalink)
References <qNHbk-8sH-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


If no script is specified for stat data, display
stat events in raw form.

  $ perf stat record ls

  SNIP

   Performance counter stats for 'ls':

            0.851585      task-clock (msec)         #    0.717 CPUs utilized
                   0      context-switches          #    0.000 K/sec
                   0      cpu-migrations            #    0.000 K/sec
                 114      page-faults               #    0.134 M/sec
           2,620,918      cycles                    #    3.078 GHz
     <not supported>      stalled-cycles-frontend
     <not supported>      stalled-cycles-backend
           2,714,111      instructions              #    1.04  insns per cycle
             542,434      branches                  #  636.970 M/sec
              15,946      branch-misses             #    2.94% of all branches

         0.001186954 seconds time elapsed

  $ perf script
  CPU   THREAD             VAL             ENA             RUN            TIME EVENT
   -1    26185          851585          851585          851585         1186954 task-clock
   -1    26185               0          851585          851585         1186954 context-switches
   -1    26185               0          851585          851585         1186954 cpu-migrations
   -1    26185             114          851585          851585         1186954 page-faults
   -1    26185         2620918          853340          853340         1186954 cycles
   -1    26185               0               0               0         1186954 stalled-cycles-frontend
   -1    26185               0               0               0         1186954 stalled-cycles-backend
   -1    26185         2714111          853340          853340         1186954 instructions
   -1    26185          542434          853340          853340         1186954 branches
   -1    26185           15946          853340          853340         1186954 branch-misses

Tested-by: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/n/tip-ph7bpnetmskvmietfwllf6i6@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-script.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 521e3e0e7625..c298cdc618e2 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -677,10 +677,46 @@ static void process_event(struct perf_script *script __maybe_unused, union perf_
 
 static struct scripting_ops	*scripting_ops;
 
+static void __process_stat(struct perf_evsel *counter, u64 time)
+{
+	int nthreads = thread_map__nr(counter->threads);
+	int ncpus = perf_evsel__nr_cpus(counter);
+	int cpu, thread;
+	static int header_printed;
+
+	if (counter->system_wide)
+		nthreads = 1;
+
+	if (!header_printed) {
+		printf("%3s %8s %15s %15s %15s %15s %s\n",
+		       "CPU", "THREAD", "VAL", "ENA", "RUN", "TIME", "EVENT");
+		header_printed = 1;
+	}
+
+	for (thread = 0; thread < nthreads; thread++) {
+		for (cpu = 0; cpu < ncpus; cpu++) {
+			struct perf_counts_values *counts;
+
+			counts = perf_counts(counter->counts, cpu, thread);
+
+			printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n",
+				counter->cpus->map[cpu],
+				thread_map__pid(counter->threads, thread),
+				counts->val,
+				counts->ena,
+				counts->run,
+				time,
+				perf_evsel__name(counter));
+		}
+	}
+}
+
 static void process_stat(struct perf_evsel *counter, u64 time)
 {
 	if (scripting_ops && scripting_ops->process_stat)
 		scripting_ops->process_stat(&stat_config, counter, time);
+	else
+		__process_stat(counter, time);
 }
 
 static void process_stat_interval(u64 time)
-- 
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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv8 0/8] perf stat: Add scripting support Jiri Olsa <jolsa@kernel.org> - 2016-01-05 22:20 +0100
  [PATCH 5/8] perf script: Add stat default handlers Jiri Olsa <jolsa@kernel.org> - 2016-01-05 22:20 +0100
    [tip:perf/core] perf script: Add stat default handlers tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-01-09 17:40 +0100
  [PATCH 1/8] perf stat record: Keep sample_type 0 for pipe session Jiri Olsa <jolsa@kernel.org> - 2016-01-05 22:20 +0100
    [tip:perf/core] perf stat record:   Keep sample_type 0 for pipe session tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-01-09 17:30 +0100
  [PATCH 8/8] perf script: Add stat-cpi.py script Jiri Olsa <jolsa@kernel.org> - 2016-01-05 22:20 +0100
    Re: [PATCH 8/8] perf script: Add stat-cpi.py script Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-06 00:00 +0100
  [PATCH 6/8] perf script: Display stat events by default Jiri Olsa <jolsa@kernel.org> - 2016-01-05 22:20 +0100
    Re: [PATCH 6/8] perf script: Display stat events by default Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-05 23:50 +0100
      Re: [PATCH 6/8] perf script: Display stat events by default Jiri Olsa <jolsa@redhat.com> - 2016-01-06 10:40 +0100
  [PATCH 2/8] perf script: Process cpu/threads maps Jiri Olsa <jolsa@kernel.org> - 2016-01-05 22:20 +0100
    [tip:perf/core] perf script: Process cpu/threads maps tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-01-09 17:30 +0100
  [PATCH 4/8] perf script: Add process_stat/process_stat_interval scripting interface Jiri Olsa <jolsa@kernel.org> - 2016-01-05 22:20 +0100
    [tip:perf/core] perf script: Add process_stat/  process_stat_interval scripting interface tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-01-09 17:40 +0100
  Re: [PATCHv8 0/8] perf stat: Add scripting support Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-05 23:40 +0100
    Re: [PATCHv8 0/8] perf stat: Add scripting support Jiri Olsa <jolsa@redhat.com> - 2016-01-06 10:10 +0100

csiph-web