kernel-fxtec-pro1x/tools/perf/scripts/python
Jiri Olsa b8a1962d17 perf script: Add stat-cpi.py script
Adding stat-cpi.py as an example of how to do stat scripting.

It computes the CPI metrics from cycles and instructions events.

The CPI is based performance metric showing the Cycles Per Instructions
ratio, which helps to identify cycles-hungry code.

Following stat record/report/script combinations could be used:

- get CPI for given workload

    $ perf stat -e cycles,instructions record ls

    SNIP

     Performance counter stats for 'ls':

             2,904,431      cycles
             3,346,878      instructions              #    1.15  insns per cycle

           0.001782686 seconds time elapsed

    $ perf script -s ./scripts/python/stat-cpi.py
           0.001783: cpu -1, thread -1 -> cpi 0.867803 (2904431/3346878)

    $ perf stat -e cycles,instructions record ls | perf script -s ./scripts/python/stat-cpi.py

    SNIP

           0.001730: cpu -1, thread -1 -> cpi 0.869026 (2928292/3369627)

- get CPI systemwide:

    $ perf stat -e cycles,instructions -a -I 1000 record sleep 3
    #           time             counts unit events
         1.000158618        594,274,711      cycles                     (100.00%)
         1.000158618        441,898,250      instructions
         2.000350973        567,649,705      cycles                     (100.00%)
         2.000350973        432,669,206      instructions
         3.000559210        561,940,430      cycles                     (100.00%)
         3.000559210        420,403,465      instructions
         3.000670798            780,105      cycles                     (100.00%)
         3.000670798            326,516      instructions

    $ perf script -s ./scripts/python/stat-cpi.py
           1.000159: cpu -1, thread -1 -> cpi 1.344823 (594274711/441898250)
           2.000351: cpu -1, thread -1 -> cpi 1.311972 (567649705/432669206)
           3.000559: cpu -1, thread -1 -> cpi 1.336669 (561940430/420403465)
           3.000671: cpu -1, thread -1 -> cpi 2.389178 (780105/326516)

    $ perf stat -e cycles,instructions -a -I 1000 record sleep 3 | perf script -s ./scripts/python/stat-cpi.py
           1.000202: cpu -1, thread -1 -> cpi 1.035091 (940778881/908885530)
           2.000392: cpu -1, thread -1 -> cpi 1.442600 (627493992/434974455)
           3.000545: cpu -1, thread -1 -> cpi 1.353612 (741463930/547766890)
           3.000622: cpu -1, thread -1 -> cpi 2.642110 (784083/296764)

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-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-01-06 20:11:16 -03:00
..
bin perf scripts python: Add new compaction-times script 2015-08-28 14:53:40 -03:00
Perf-Trace-Util perf build: Add scripts objects building 2015-02-12 11:49:53 -03:00
call-graph-from-postgresql.py perf tools: Add example call-graph script 2015-08-21 12:32:40 -03:00
check-perf-trace.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
compaction-times.py perf scripts python: Add new compaction-times script 2015-08-28 14:53:40 -03:00
event_analyzing_sample.py perf script python: Correct handler check and spelling errors 2012-08-09 13:26:19 -03:00
export-to-postgresql.py perf tools: Add more documentation to export-to-postgresql.py script 2015-09-28 16:53:07 -03:00
failed-syscalls-by-pid.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
futex-contention.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
net_dropmonitor.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
netdev-times.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
sched-migration.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
sctop.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
stat-cpi.py perf script: Add stat-cpi.py script 2016-01-06 20:11:16 -03:00
syscall-counts-by-pid.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
syscall-counts.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00