2011-08-25 24 views
3

我試圖使用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.發生什麼事了?有其他選擇嗎?

[我很困惑是否應該留在這兒或在serverfault張貼]

+1

的時間命令只能輸出值如果跟蹤已經被編譯到內核中。我甚至不知道是否有任何跟蹤代碼曾經被寫入這些特定的參數... – Neil

+2

嘗試計數套接字調用的strace –

+0

是的,我正在嘗試'strace -c' ...試圖找出如何grep是數據到我需要的抽象級別。 – Tathagata

回答

1

我認爲它不使用Linux;自從你說「strace」以後,我假設你使用的是Linux。該手冊頁說:

Bugs 

Not all resources are measured by all versions of Unix, 
so some of the values might be reported as zero. The present 
selection was mostly inspired by the data provided by 4.2 or 
4.3BSD. 

我試過「的wget」的OSX系統上(這是BSD-ISH),以檢查它是否報告插座的統計數據,並有至少插座的工作原理:

0.00 user, 
0.01 system, 
1% CPU, 
0 max-mem footprint in KB, 
0 avg-mem footprint in KB, 
0 Average total (data+stack+text) memory, 
0 major page faults, 
0 file system inputs by the process, 
0 file system outputs by the process, 
151 socket messages received, 
8 socket messages sent, 
0 status 

希望有幫助, 亞歷克斯。

0

不要使用time的基準。 time命令的某些字段按照[1]中指定的方式斷開。然而,時間的基本功能(真實,用戶和CPU時間)仍然完好無損。

[1] Maximum resident set size does not make sense

+0

有趣!感謝分享 - 我已經擺脫了懶惰,並試圖用時間命令對基準進行基準測試。 – Tathagata