测量程序的计算时间和I / O时间

时间:2012-05-02 15:06:32

标签: performance profiling timing

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

编辑:这是Linux 64位程序

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

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