diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 21:31:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 21:31:30 -0400 |
commit | a926021cb1f8a99a275eaf6eb546102e9469dc59 (patch) | |
tree | c6d0300cd4b1a1fd658708476db4577b68b4de31 /tools/perf/python/twatch.py | |
parent | 0586bed3e8563c2eb89bc7256e30ce633ae06cfb (diff) | |
parent | 5e814dd597c42daeb8d2a276e64a6ec986ad0e2a (diff) |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (184 commits)
perf probe: Clean up probe_point_lazy_walker() return value
tracing: Fix irqoff selftest expanding max buffer
tracing: Align 4 byte ints together in struct tracer
tracing: Export trace_set_clr_event()
tracing: Explain about unstable clock on resume with ring buffer warning
ftrace/graph: Trace function entry before updating index
ftrace: Add .ref.text as one of the safe areas to trace
tracing: Adjust conditional expression latency formatting.
tracing: Fix event alignment: skb:kfree_skb
tracing: Fix event alignment: mce:mce_record
tracing: Fix event alignment: kvm:kvm_hv_hypercall
tracing: Fix event alignment: module:module_request
tracing: Fix event alignment: ftrace:context_switch and ftrace:wakeup
tracing: Remove lock_depth from event entry
perf header: Stop using 'self'
perf session: Use evlist/evsel for managing perf.data attributes
perf top: Don't let events to eat up whole header line
perf top: Fix events overflow in top command
ring-buffer: Remove unused #include <linux/trace_irq.h>
tracing: Add an 'overwrite' trace_option.
...
Diffstat (limited to 'tools/perf/python/twatch.py')
-rwxr-xr-x | tools/perf/python/twatch.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/perf/python/twatch.py b/tools/perf/python/twatch.py new file mode 100755 index 000000000000..df638c438a9f --- /dev/null +++ b/tools/perf/python/twatch.py | |||
@@ -0,0 +1,41 @@ | |||
1 | #! /usr/bin/python | ||
2 | # -*- python -*- | ||
3 | # -*- coding: utf-8 -*- | ||
4 | # twatch - Experimental use of the perf python interface | ||
5 | # Copyright (C) 2011 Arnaldo Carvalho de Melo <acme@redhat.com> | ||
6 | # | ||
7 | # This application is free software; you can redistribute it and/or | ||
8 | # modify it under the terms of the GNU General Public License | ||
9 | # as published by the Free Software Foundation; version 2. | ||
10 | # | ||
11 | # This application is distributed in the hope that it will be useful, | ||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | # General Public License for more details. | ||
15 | |||
16 | import perf | ||
17 | |||
18 | def main(): | ||
19 | cpus = perf.cpu_map() | ||
20 | threads = perf.thread_map() | ||
21 | evsel = perf.evsel(task = 1, comm = 1, mmap = 0, | ||
22 | wakeup_events = 1, sample_period = 1, | ||
23 | sample_id_all = 1, | ||
24 | sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_TID) | ||
25 | evsel.open(cpus = cpus, threads = threads); | ||
26 | evlist = perf.evlist(cpus, threads) | ||
27 | evlist.add(evsel) | ||
28 | evlist.mmap() | ||
29 | while True: | ||
30 | evlist.poll(timeout = -1) | ||
31 | for cpu in cpus: | ||
32 | event = evlist.read_on_cpu(cpu) | ||
33 | if not event: | ||
34 | continue | ||
35 | print "cpu: %2d, pid: %4d, tid: %4d" % (event.sample_cpu, | ||
36 | event.sample_pid, | ||
37 | event.sample_tid), | ||
38 | print event | ||
39 | |||
40 | if __name__ == '__main__': | ||
41 | main() | ||