History

perf script: Add stackcollapse.py script

Add stackcollapse.py script as an example of parsing call chains, and also of using optparse to access command line options. The flame graph tools include a set of scripts that parse output from various tools (including "perf script"), remove the offsets in the function and collapse each stack to a single line. The website also says "perf report could have a report style [...] that output folded stacks directly, obviating the need for stackcollapse-perf.pl", so here it is. This script is a Python rewrite of stackcollapse-perf.pl, using the perf scripting interface to access the perf data directly from Python.

Paolo Bonzini committed 10 years ago

Commit 6745d8e1 parent 7da36e93 files · +138 −0Browse files

Showing the changes to tools/perf/scripts/python/bin (2 of 3 files). Show all

Unified · Split

2 files
  1. tools/perf/scripts/python/bin/stackcollapse-record +8 −0
  2. tools/perf/scripts/python/bin/stackcollapse-report +3 −0
tools/perf/scripts/python/bin/stackcollapse-record+8−0
@@ -0,0 +1,8 @@
1+#!/bin/sh
2+
3+#
4+# stackcollapse.py can cover all type of perf samples including
5+# the tracepoints, so no special record requirements, just record what
6+# you want to analyze.
7+#
8+perf record "$@"
tools/perf/scripts/python/bin/stackcollapse-report+3−0
@@ -0,0 +1,3 @@
1+#!/bin/sh
2+# description: produce callgraphs in short form for scripting use
3+perf script -s "$PERF_EXEC_PATH"/scripts/python/stackcollapse.py -- "$@"