Time除了监控程序运行时间还能干这个?
time是我們比較常用的一個在bash終端監控程序運行的小工具,如
time sleep 2real 0m2.003s 整個程序運行耗時,從運行開始到運行結束 user 0m0.002s 程序運行過程中用戶占用的cpu時間 sys 0m0.001s 程序運行過程中系統占用的CPU時間那如果我們想監控程序的運行內存怎么辦?我們可以調用系統的time,而不是bash的time,什么區別呢?
type time # 這是bash中的time time 是 shell 關鍵字# 這是系統的time which time /usr/bin/time這時我們通常需要全路徑去調用,例如
# /usr/bin/time -v command /usr/bin/time -v STAR --runMode genomeGenerate --runThreadN 10 --genomeDir star_GRCh38 --genomeFastaFiles GRCh38.fa --sjdbGTFfile GRCh38.gtf返回如下信息:
Aug 31 16:51:51 ..... started STAR run Aug 31 16:51:51 ... starting to generate Genome files Aug 31 16:51:52 ..... processing annotations GTF Aug 31 16:51:53 ... starting to sort Suffix Array. This may take a long time... Aug 31 16:51:54 ... sorting Suffix Array chunks and saving them to disk... Aug 31 16:52:10 ... loading chunks from disk, packing SA... Aug 31 16:52:13 ... finished generating suffix array Aug 31 16:52:13 ... generating Suffix Array index Aug 31 16:52:45 ... completed Suffix Array index Aug 31 16:52:45 ..... inserting junctions into the genome indices Aug 31 16:53:05 ... writing Genome to disk ... Aug 31 16:53:06 ... writing Suffix Array to disk ... Aug 31 16:53:09 ... writing SAindex to disk Aug 31 16:53:21 ..... finished successfullyCommand being timed: "STAR --runMode genomeGenerate --runThreadN 10 --genomeDir star_GRCh38 --genomeFastaFiles GRCh38.fa --sjdbGTFfile GRCh38.gtf"# 用戶占用CPU的時間User time (seconds): 191.97# 系統占用CPU的時間System time (seconds): 11.18# 用戶額CPU使用率;雖然指定了10個線程,但只達到了雙核效率,快了2倍Percent of CPU this job got: 223%# 程序從開始運行到結束的時間,人為感覺到的運行了多久Elapsed (wall clock) time (h:mm:ss or m:ss): 1:30.93 # 下面5項未做統計,都給予了0Average shared text size (kbytes): 0Average unshared data size (kbytes): 0Average stack size (kbytes): 0Average total size (kbytes): 0Average resident set size (kbytes): 0# 該進程占用的最大物理內存, 2.3GMaximum resident set size (kbytes): 2306644# 數據未讀入內存,從硬盤讀取后緩存入內存Major (requiring I/O) page faults: 0# 已讀入內存緩存區的數據Minor (reclaiming a frame) page faults: 2451338# 程序自動放棄CPU使用權的次數Voluntary context switches: 293# 程序被動放棄CPU使用權的次數Involuntary context switches: 434Swaps: 0# 總的讀寫字符數File system inputs: 0File system outputs: 6246432Socket messages sent: 0Socket messages received: 0Signals delivered: 0Page size (bytes): 4096Exit status: 0有了這個工具,下一步就可以愉快的評估不同的軟件、數據量所使用的計算資源多少,進而指導電腦裝機了。
References
https://stackoverflow.com/questions/60779173/what-does-maximum-resident-set-size-mean
https://www.gnu.org/software/time/
https://ftp.gnu.org/gnu/time/
https://stackoverflow.com/questions/998517/problem-with-the-gnu-time-command-to-measure-memory-usage
https://superuser.com/questions/480928/is-there-any-command-like-time-but-for-memory-usage
https://stackoverflow.com/questions/131303/how-can-i-measure-the-actual-memory-usage-of-an-application-or-process
https://stackoverflow.com/questions/774556/peak-memory-usage-of-a-linux-unix-process/774601#774601
https://bugzilla.redhat.com/show_bug.cgi?id=702826
https://www.slashroot.in/linux-system-io-monitoring
總結
以上是生活随笔為你收集整理的Time除了监控程序运行时间还能干这个?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于召开中国医药教育协会医学基因组学与生
- 下一篇: 精选| 2021年9月R新包推荐(第58