diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-10-26 09:30:22 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-10-26 09:30:22 +0200 |
commit | 5df414c61e1b6f15bdc3759f292c7404286c9827 (patch) | |
tree | 41b50a595fc53de595edcc20b350c048ce2856fc /tools/perf/scripts/python/syscall-counts-by-pid.py | |
parent | 0b849ee88846e3488a34007c5b8b4249579ff159 (diff) | |
parent | 7f6c1bd50d73d12f8b4ea09edb4515997f6527f5 (diff) | |
download | linux-5df414c61e1b6f15bdc3759f292c7404286c9827.tar.gz linux-5df414c61e1b6f15bdc3759f292c7404286c9827.tar.bz2 linux-5df414c61e1b6f15bdc3759f292c7404286c9827.zip |
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/urgent
Diffstat (limited to 'tools/perf/scripts/python/syscall-counts-by-pid.py')
-rw-r--r-- | tools/perf/scripts/python/syscall-counts-by-pid.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tools/perf/scripts/python/syscall-counts-by-pid.py b/tools/perf/scripts/python/syscall-counts-by-pid.py index af722d6a4b3f..d1ee3ec10cf2 100644 --- a/tools/perf/scripts/python/syscall-counts-by-pid.py +++ b/tools/perf/scripts/python/syscall-counts-by-pid.py @@ -5,29 +5,33 @@ # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. -import os -import sys +import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * +from Util import syscall_name usage = "perf trace -s syscall-counts-by-pid.py [comm]\n"; for_comm = None +for_pid = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: - for_comm = sys.argv[1] + try: + for_pid = int(sys.argv[1]) + except: + for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): - pass + print "Press control+C to stop and show the summary" def trace_end(): print_syscall_totals() @@ -35,9 +39,10 @@ def trace_end(): def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): - if for_comm is not None: - if common_comm != for_comm: - return + + if (for_comm and common_comm != for_comm) or \ + (for_pid and common_pid != for_pid ): + return try: syscalls[common_comm][common_pid][id] += 1 except TypeError: @@ -61,4 +66,4 @@ def print_syscall_totals(): id_keys = syscalls[comm][pid].keys() for id, val in sorted(syscalls[comm][pid].iteritems(), \ key = lambda(k, v): (v, k), reverse = True): - print " %-38d %10d\n" % (id, val), + print " %-38s %10d\n" % (syscall_name(id), val), |