使用 time 命令进行基准测试
我正在尝试使用 time
命令作为一个简单的解决方案来对一些执行大量文本处理并进行大量网络调用的脚本进行基准测试。为了评估它是否合适,我尝试执行:
/usr/bin/time -f "\n%E elapsed,\n%U user,\n%S system, \n %P CPU, \n%M
max-mem footprint in KB, \n%t avg-mem footprint in KB, \n%K Average total
(data+stack+text) memory,\n%F major page faults, \n%I file system
inputs by the process, \n%O file system outputs by the process, \n%r
socket messages received, \n%s socket messages sent, \n%x status" yum
install nmap
并得到:
1:35.15 elapsed,
3.17 user,
0.40 system,
3% CPU,
0 max-mem footprint in KB,
0 avg-mem footprint in KB,
0 Average total (data+stack+text) memory,
127 major page faults,
0 file system inputs by the process,
0 file system outputs by the process,
0 socket messages received,
0 socket messages sent,
0 status
这并不完全是我所期望的 - 特别是 0 值。即使我将命令更改为 ping google.com
,套接字消息仍为 0。这是怎么回事?还有其他选择吗?
[我很困惑它是否应该留在这里或发布在服务器故障中]
I'm trying to use the time
command as a simple solution for benchmarking some scripts that do a lot of text processing and makes a number of network calls. To evaluate if its a good fit, I tried doing:
/usr/bin/time -f "\n%E elapsed,\n%U user,\n%S system, \n %P CPU, \n%M
max-mem footprint in KB, \n%t avg-mem footprint in KB, \n%K Average total
(data+stack+text) memory,\n%F major page faults, \n%I file system
inputs by the process, \n%O file system outputs by the process, \n%r
socket messages received, \n%s socket messages sent, \n%x status" yum
install nmap
and got:
1:35.15 elapsed,
3.17 user,
0.40 system,
3% CPU,
0 max-mem footprint in KB,
0 avg-mem footprint in KB,
0 Average total (data+stack+text) memory,
127 major page faults,
0 file system inputs by the process,
0 file system outputs by the process,
0 socket messages received,
0 socket messages sent,
0 status
which is not exactly what I was expecting - specially the 0 values. Even when I change the command to say ping google.com
, the socket messages are 0. What's going on? Is there any alternative?
[And I'm confused if it should stay here or be posted in serverfault]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为它不适用于 Linux;我假设你正在使用Linux,因为你说“strace”。手册页说:
我在 OSX 系统(BSD-ish)上尝试了“wget”来检查它是否报告套接字统计信息,并且至少套接字可以工作:
希望有帮助,
亚历克斯.
I think it's not working with Linux; I assume you're using Linux since you said "strace". The manual page says:
I tried "wget" on an OSX system (which is BSD-ish) to check if it report socket statistics, and there at least socket works:
Hope that helps,
Alex.
不要使用
时间
来进行基准测试。time
命令的某些字段已损坏,如 [1] 中指定的那样。然而,时间的基本功能(实际时间、用户时间和CPU时间)仍然完好无损。[1] 最大驻留集大小没有意义
Do not use
time
to benchmark. Some of the fields of thetime
command is broken as specified in [1]. However the basic functionality of time (real , user and cpu time) are still intact.[1] Maximum resident set size does not make sense