aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/syscall-counts.py
blob: e66a7730aeb5de966b25d9f6401188d0db7c305b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# system call counts
# (c) 2010, Tom Zanussi <tzanussi@gmail.com>
# Licensed under the terms of the GNU GPL License version 2
#
# 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

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 script -s syscall-counts.py [comm]\n";

for_comm = None

if len(sys.argv) > 2:
	sys.exit(usage)

if len(sys.argv) > 1:
	for_comm = sys.argv[1]

syscalls = autodict()

def trace_begin():
	print "Press control+C to stop and show the summary"

def trace_end():
	print_syscall_totals()

def raw_syscalls__sys_enter(event_name, context, common_cpu,
	common_secs, common_nsecs, common_pid, common_comm,
	common_callchain, id, args):
	if for_comm is not None:
		if common_comm != for_comm:
			return
	try:
		syscalls[id] += 1
	except TypeError:
		syscalls[id] = 1

def syscalls__sys_enter(event_name, context, common_cpu,
	common_secs, common_nsecs, common_pid, common_comm,
	id, args):
	raw_syscalls__sys_enter(**locals())

def print_syscall_totals():
    if for_comm is not None:
	    print "\nsyscall events for %s:\n\n" % (for_comm),
    else:
	    print "\nsyscall events:\n\n",

    print "%-40s  %10s\n" % ("event", "count"),
    print "%-40s  %10s\n" % ("----------------------------------------", \
                                 "-----------"),

    for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
				  reverse = True):
	    print "%-40s  %10d\n" % (syscall_name(id), val),
td>Junio C Hamano2-1/+5 2020-01-08graph: fix lack of color in horizontal linesDerrick Stolee2-4/+38 2020-01-08graph: drop assert() for merge with two collapsing parentsDerrick Stolee2-4/+42 2020-01-06The final batch before -rc2Junio C Hamano1-2/+18 2020-01-06doc: submodule: fix typo for command absorbgitdirsThomas Menzel1-1/+1 2020-01-06l10n: es: 2.25.0 round #1Christopher Diaz Riveros1-2282/+2838 2020-01-04am: document that Date: can appear as an in-body headerPaul Menzel1-2/+2 2020-01-04gitweb: fix a couple spelling errors in commentsDenis Ovsienko1-2/+2 2020-01-04multi-pack-index: correct configuration in documentationJohannes Berg1-1/+1 2020-01-04Documentation/git-sparse-checkout.txt: fix a typoTaylor Blau1-1/+1 2020-01-04l10n: sv.po: Update Swedish translation (4800t0f0u)Peter Krefting1-2282/+2825 2020-01-03l10n: fr.po v2.25.0 rnd 1Jean-Noël Avila1-2271/+2800 2020-01-03l10n: vi(4800t): Updated Vietnamese translation v2.25.0Tran Ngoc Quan1-2273/+2839 2020-01-02commit-graph: prefer default size_mult when given zeroDerrick Stolee2-4/+4 2020-01-02mingw: only test index entries for backslashes, not tree entriesJohannes Schindelin3-9/+9 2020-01-02Git 2.25-rc1v2.25.0-rc1Junio C Hamano2-1/+14 2020-01-02merge-recursive: remove unnecessary oid_eq functionElijah Newren1-22/+11 2020-01-02sparse-checkout: use extern for global variablesDerrick Stolee1-2/+2 2019-12-31l10n: zh_TW.po: update translation for v2.25.0 round 1pan934121-2343/+2974 2019-12-31git-gui: allow opening currently selected file in default appZoli Szabó1-5/+24 2019-12-30sparse-checkout: document interactions with submodulesDerrick Stolee2-0/+38 2019-12-30sparse-checkout: list directories in cone modeDerrick Stolee3-1/+42 2019-12-30l10n: it.po: update the Italian translation for Git 2.25.0Alessandro Menti1-2277/+2854 2019-12-30l10n: git.pot: v2.25.0 round 1 (119 new, 13 removed)Jiang Xin1-2252/+2755 2019-12-27t3008: find test-tool through path lookupJohannes Sixt1-1/+1 2019-12-27l10n: Update Catalan translationJordi Mas1-8/+8 2019-12-26packfile: replace lseek+read with preadEric Wong1-3/+2 2019-12-26doc: log, gitk: line-log arguments must exist in starting revisionPhilippe Blain2-2/+4 2019-12-26doc: log, gitk: document accepted line-log diff formatsPhilippe Blain2-2/+8 2019-12-26packfile: remove redundant fcntl F_GETFD/F_SETFDEric Wong1-11/+0 2019-12-26mailmap: mask accentless variant for Công DanhJunio C Hamano1-0/+1 2019-12-25Git 2.25-rc0v2.25.0-rc0Junio C Hamano2-6/+27 2019-12-21mingw: refuse paths containing reserved namesJohannes Schindelin3-18/+110 2019-12-21mingw: short-circuit the conversion of `/dev/null` to UTF-16Johannes Schindelin1-10/+16 2019-12-20sparse-checkout: improve OS ls compatibilityEd Maste1-14/+22