这两者有什么区别?手册页上写着:
-r Print a relative timestamp upon entry to each system call. This records the time difference between the beginning of
successive system calls.
-T Show the time spent in system calls. This records the time difference between the beginning and the end of each system
call.
我唯一的解释是,-T
只显示每个调用所需的时间,而-r
也考虑到在每个syscall之后等待的时间。
这似乎得到了以下事实的支持:当查看strace
在uptime
命令上的相应片段时,-r
命令在每次调用中显示的时间比下面的-T
长。见下文:
0.000039 uname({sysname="Linux", nodename="ip-172-31-55-20", ...}) = 0
0.000043 open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 3
0.000045 read(3, "0\n", 8192) = 2
0.000035 close(3) = 0
&
uname({sysname="Linux", nodename="ip-172-31-55-20", ...}) = 0 <0.000010>
open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 3 <0.000018>
read(3, "0\n", 8192) = 2 <0.000014>
close(3) = 0 <0.000023>
是这样的吗?
发布于 2016-11-24 05:33:56
没错,是的。
-r
显示的额外时间不是花在等待上的时间,而是做其他不涉及系统(计算、内存操作.)的事情的时间。
发布于 2020-02-06 14:46:27
考虑到这个回答,在计算和其他类似的东西中,strace本身肯定会花费一些时间。
strace的工作方式导致内核在每次系统调用结束时停止对程序的跟踪,所以strace可以检查它,然后继续执行。
因此,连续系统调用开始之间的时间差必须包括strace本身所花费的一些时间。
https://unix.stackexchange.com/questions/325622
复制相似问题