2016-06-29 85 views
0

我試圖使用GNU和zsh time命令的最大內存輸出,並試圖調和我在輸出中看到的差異。我的最終目標是捕獲運行不同大小數據集的程序的最高RAM使用率。要使用zsh,我一直在關注this exampleGNU和zsh時間命令之間的區別

$ zsh -i -c 'time ls' > hold 
ls --color=auto 0.00s user 0.00s system 40% cpu 0.002 total 
avg shared (code):   0 KB 
avg unshared (data/stack): 0 KB 
total (sum):    0 KB 
max memory:    0 MB 
page faults from disk:  0 
other page faults:   335 

隨着GNU的時候,我得到這個...

$ /usr/bin/time -f %M ls > hold 
3632 

認爲這GNU時間告訴我,ls使用的RAM 3.6 KB,但zsh的版本中使用無。當我重複這一過程,更耐人尋味的命令,我也得到不同...

$zsh -i -c 'time program > hold' 
program > hold 16.36s user 0.64s system 99% cpu 17.063 total 
avg shared (code):   0 KB 
avg unshared (data/stack): 0 KB 
total (sum):    0 KB 
max memory:    94 MB 
page faults from disk:  0 
other page faults:   25361 

當我看屏幕上方,它看起來像RES柱確實峯以94 MB雖然VIRT列是127 MB。通過GNU時間...

$ /usr/bin/time -f %M my_program > hold 
387088 

或〜387 MB。

任何人都可以幫助我找出爲什麼有差異和我在這裏失蹤?

+0

* zsh *'time'的輸出格式看起來不是默認設置。 'TIMEFMT'('echo $ TIMEFMT')的值是多少? – Adaephon

+0

它與此處所述的相同:http://superuser.com/questions/480928/is-there-any-command-like-time-but-for-memory-usage/767491#767491 –

回答

0

我不認爲zsh有時間命令。可能是錯誤的,但-c看起來像「運行此shell命令」,所以它正在搜索您的路徑time,並可能找到相同的/usr/bin/time你在bash中運行。

可能的區別在於格式。嘗試將相同的-f傳遞給zsh調用。

http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html沒有顯示內置時間。您正在以兩種方式運行理智命令(取決於路徑中的內容)。

相關問題