1

是否有任何程序可以测量给定程序的总计算时间和总 I/O 时间(写入标准输出或文件)?

编辑:这是 Linux 64 位程序

4

2 回答 2

1

时间

$ time echo "hello world"
hello world

real    0m0.000s
user    0m0.000s
sys     0m0.000s

strace -c

$ strace -c echo "hello world"
hello world
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
   nan    0.000000           0         1           read
   nan    0.000000           0         1           write
   nan    0.000000           0        14        12 open
   nan    0.000000           0         3           close
   nan    0.000000           0        12         9 stat
   nan    0.000000           0         3           fstat
   nan    0.000000           0         8           mmap
   nan    0.000000           0         3           mprotect
   nan    0.000000           0         2           munmap
   nan    0.000000           0         3           brk
   nan    0.000000           0         1         1 access
   nan    0.000000           0         1           execve
   nan    0.000000           0         1           uname
   nan    0.000000           0         1           arch_prctl
------ ----------- ----------- --------- --------- ----------------
100.00    0.000000                    54        22 total
于 2012-05-02T20:21:57.153 回答
0

您可以使用该time命令获取进程占用的总挂钟和总 CPU 时间。这将为您提供合理的估计,尤其是对于 I/O 繁重的进程。

于 2012-05-02T20:17:32.707 回答