diff options
author | Mark Hills <Mark.Hills@framestore.com> | 2014-05-28 17:52:40 +0100 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2014-05-29 18:15:38 +0000 |
commit | e53bf23f1c33076090b51184b82af4dd98d0c51c (patch) | |
tree | b41cd1f1b1e0ab69be2cd4f0810426cf4a0f2711 /strace.c | |
parent | ac5133d0cb5c18a39f6fa9b7ca2ebcba9277a904 (diff) | |
download | android_external_strace-e53bf23f1c33076090b51184b82af4dd98d0c51c.tar.gz android_external_strace-e53bf23f1c33076090b51184b82af4dd98d0c51c.tar.bz2 android_external_strace-e53bf23f1c33076090b51184b82af4dd98d0c51c.zip |
Optionally produce stats on syscall latency
Time spent in system time is not useful where a syscall depends on some
non-CPU resource, eg. typically open() or stat() to a network drive.
This patch adds a new flag (-w) to produce a summary of the time
difference between beginning and end of the system call (ie. latency)
This functionality has been useful to profile slow processes that
are not CPU-bound.
Signed-off-by: Mark Hills <mark.hills@framestore.com>
Diffstat (limited to 'strace.c')
-rw-r--r-- | strace.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -78,6 +78,7 @@ bool need_fork_exec_workarounds = 0; bool debug_flag = 0; bool Tflag = 0; bool iflag = 0; +bool count_wallclock = 0; unsigned int qflag = 0; /* Which WSTOPSIG(status) value marks syscall traps? */ static unsigned int syscall_trap_sig = SIGTRAP; @@ -200,6 +201,7 @@ usage: strace [-CdffhiqrtttTvVxxy] [-I n] [-e expr]...\n\ -p pid... / [-D] [-E var=val]... [-u username] PROG [ARGS]\n\ -c -- count time, calls, and errors for each syscall and report summary\n\ -C -- like -c but also print regular output\n\ +-w -- summarise syscall latency (default is system time)\n\ -d -- enable debug output to stderr\n\ -D -- run tracer process as a detached grandchild, not as parent\n\ -f -- follow forks, -ff -- with output into separate files\n\ @@ -1650,7 +1652,7 @@ init(int argc, char *argv[]) #endif qualify("signal=all"); while ((c = getopt(argc, argv, - "+b:cCdfFhiqrtTvVxyz" + "+b:cCdfFhiqrtTvVwxyz" "D" "a:e:o:O:p:s:S:u:E:P:I:")) != EOF) { switch (c) { @@ -1702,6 +1704,9 @@ init(int argc, char *argv[]) case 'T': Tflag = 1; break; + case 'w': + count_wallclock = 1; + break; case 'x': xflag++; break; @@ -1791,6 +1796,10 @@ init(int argc, char *argv[]) error_msg_and_die("(-c or -C) and -ff are mutually exclusive"); } + if (count_wallclock && !cflag) { + error_msg_and_die("-w must be given with (-c or -C)"); + } + /* See if they want to run as another user. */ if (username != NULL) { struct passwd *pent; |