strace
strace -cp 1
命令输出:
strace: Process 1 attached
strace: Process 1 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
28.09 0.000084 16 5 clone
13.04 0.000039 7 5 timerfd_settime
12.71 0.000038 6 6 epoll_wait
11.04 0.000033 6 5 ioctl
9.70 0.000029 4 6 read
perf
perf trace -p $pid --duration 50
命令输出如下:
0.076 (1249.922 ms): epoll_wait(epfd: 4<anon_inode:[eventpoll]>, events: 0x7ffe92ab3af0, maxevents: 36, timeout: 4294967295) = 1
1250.074 (1249.927 ms): epoll_wait(epfd: 4<anon_inode:[eventpoll]>, events: 0x7ffe92ab3af0, maxevents: 36, timeout: 4294967295) = 1
2500.076 (1249.924 ms): epoll_wait(epfd: 4<anon_inode:[eventpoll]>, events: 0x7ffe92ab3af0, maxevents: 36, timeout: 4294967295) = 1
perf trace -p $pid --duration 50 --call-graph dwarf -o savefile.txt
命令输出如下:
0.409 (1249.593 ms): epoll_wait(epfd: 4<anon_inode:[eventpoll]>, events: 0x7ffe92ab3af0, maxevents: 36, timeout: 4294967295) = 1
[0xffff80d79646ceb3] (/usr/lib64/libc-2.17.so)
[0xffffaa31d86cf058] (/usr/lib/systemd/systemd)
[0xffffaa31d86cfb6c] (/usr/lib/systemd/systemd)
[0xffffaa31d862db82] (/usr/lib/systemd/systemd)
[0xffffaa31d8621f27] (/usr/lib/systemd/systemd)
__libc_start_main (/usr/lib64/libc-2.17.so)
[0xffffaa31d8623f8b] (/usr/lib/systemd/systemd)