Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf script: Display stat events by default

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

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1452077397-31958-3-git-send-email-jolsa@kernel.org
[ Rename 'time' parameter to 'tstamp' to fix build on older distros ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
36e33c53 15d2b995

+36
+36
tools/perf/builtin-script.c
··· 677 677 678 678 static struct scripting_ops *scripting_ops; 679 679 680 + static void __process_stat(struct perf_evsel *counter, u64 tstamp) 681 + { 682 + int nthreads = thread_map__nr(counter->threads); 683 + int ncpus = perf_evsel__nr_cpus(counter); 684 + int cpu, thread; 685 + static int header_printed; 686 + 687 + if (counter->system_wide) 688 + nthreads = 1; 689 + 690 + if (!header_printed) { 691 + printf("%3s %8s %15s %15s %15s %15s %s\n", 692 + "CPU", "THREAD", "VAL", "ENA", "RUN", "TIME", "EVENT"); 693 + header_printed = 1; 694 + } 695 + 696 + for (thread = 0; thread < nthreads; thread++) { 697 + for (cpu = 0; cpu < ncpus; cpu++) { 698 + struct perf_counts_values *counts; 699 + 700 + counts = perf_counts(counter->counts, cpu, thread); 701 + 702 + printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n", 703 + counter->cpus->map[cpu], 704 + thread_map__pid(counter->threads, thread), 705 + counts->val, 706 + counts->ena, 707 + counts->run, 708 + tstamp, 709 + perf_evsel__name(counter)); 710 + } 711 + } 712 + } 713 + 680 714 static void process_stat(struct perf_evsel *counter, u64 tstamp) 681 715 { 682 716 if (scripting_ops && scripting_ops->process_stat) 683 717 scripting_ops->process_stat(&stat_config, counter, tstamp); 718 + else 719 + __process_stat(counter, tstamp); 684 720 } 685 721 686 722 static void process_stat_interval(u64 tstamp)