[英]How to use time command on nested command?
我需要使用GNU time
命令來衡量我編寫的程序,所以我嘗試了
/usr/bin/time -v cat test/testin | ./db retrieve >> test/result
但是輸出的第一行顯示
Command being timed: "cat test/testin"
而用戶時間和系統時間分別是
User time (seconds): 0.00 System time (seconds): 0.02 Percent of CPU this job got: 0% Elapsed (wall clock) time (h:mm:ss or m:ss): 2:02.73
這表明它沒有計入我的程序使用的時間,因為該程序應該在相當大的CPU使用率下運行2分鍾或更長時間。
就您而言,您可以簡單地省略UUOC。 在一般情況下,您可以
time sh -c "cmd | cmd"
/usr/bin/time -v ./db retrieve < test/testin >> test/result
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.