| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 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, watermark = 1,
|
| 23 | sample_id_all = 1,
|
| 24 | sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU)
|
| 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()
|