Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234376
b: refs/heads/master
c: 877108e
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 30, 2011
1 parent f83a4a7 commit 81b4622
Show file tree
Hide file tree
Showing 5 changed files with 967 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8115d60c323dd9931b95221c0a392aeddc1d6ef3
refs/heads/master: 877108e42b1b9ba64857c4030cf356ecc120fd18
20 changes: 19 additions & 1 deletion trunk/tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ COMPAT_CFLAGS =
COMPAT_OBJS =
LIB_H =
LIB_OBJS =
PYRF_OBJS =
SCRIPT_PERL =
SCRIPT_SH =
TEST_PROGRAMS =
Expand All @@ -324,6 +325,9 @@ SCRIPT_SH += perf-archive.sh
grep-libs = $(filter -l%,$(1))
strip-libs = $(filter-out -l%,$(1))

pyrf: $(PYRF_OBJS)
python util/setup.py build --build-base='$(OUTPUT)'

#
# No Perl scripts right now:
#
Expand All @@ -349,7 +353,7 @@ PROGRAMS += $(OUTPUT)perf
#

# what 'all' will build and 'install' will install, in perfexecdir
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) pyrf

# what 'all' will build but not install in perfexecdir
OTHER_PROGRAMS = $(OUTPUT)perf$X
Expand Down Expand Up @@ -520,6 +524,20 @@ BUILTIN_OBJS += $(OUTPUT)builtin-inject.o

PERFLIBS = $(LIB_FILE)

# Files needed for the python binding, perf.so
# pyrf is just an internal name needed for all those wrappers.
# This has to be in sync with what is in the 'sources' variable in
# tools/perf/util/setup.py

PYRF_OBJS += $(OUTPUT)util/cpumap.o
PYRF_OBJS += $(OUTPUT)util/ctype.o
PYRF_OBJS += $(OUTPUT)util/evlist.o
PYRF_OBJS += $(OUTPUT)util/evsel.o
PYRF_OBJS += $(OUTPUT)util/python.o
PYRF_OBJS += $(OUTPUT)util/thread_map.o
PYRF_OBJS += $(OUTPUT)util/util.o
PYRF_OBJS += $(OUTPUT)util/xyarray.o

#
# Platform specific tweaks
#
Expand Down
41 changes: 41 additions & 0 deletions trunk/tools/perf/python/twatch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#! /usr/bin/python
# -*- python -*-
# -*- coding: utf-8 -*-
# twatch - Experimental use of the perf python interface
# Copyright (C) 2011 Arnaldo Carvalho de Melo <acme@redhat.com>
#
# This application is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2.
#
# This application is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.

import perf

def main():
cpus = perf.cpu_map()
threads = perf.thread_map()
evsel = perf.evsel(task = 1, comm = 1, mmap = 0,
wakeup_events = 1, sample_period = 1,
sample_id_all = 1,
sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_TID)
evsel.open(cpus = cpus, threads = threads);
evlist = perf.evlist()
evlist.add(evsel)
evlist.mmap(cpus = cpus, threads = threads)
while True:
evlist.poll(timeout = -1)
for cpu in cpus:
event = evlist.read_on_cpu(cpu)
if not event:
continue
print "cpu: %2d, pid: %4d, tid: %4d" % (event.sample_cpu,
event.sample_pid,
event.sample_tid),
print event

if __name__ == '__main__':
main()
Loading

0 comments on commit 81b4622

Please sign in to comment.