日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Time除了监控程序运行时间还能干这个?

發(fā)布時間:2025/3/15 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Time除了监控程序运行时间还能干这个? 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

time是我們比較常用的一個在bash終端監(jiān)控程序運行的小工具,如

time sleep 2real 0m2.003s 整個程序運行耗時,從運行開始到運行結束 user 0m0.002s 程序運行過程中用戶占用的cpu時間 sys 0m0.001s 程序運行過程中系統(tǒng)占用的CPU時間

那如果我們想監(jiān)控程序的運行內存怎么辦?我們可以調用系統(tǒng)的time,而不是bash的time,什么區(qū)別呢?

type time # 這是bash中的time time 是 shell 關鍵字# 這是系統(tǒng)的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# 系統(tǒng)占用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項未做統(tǒng)計,都給予了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# 數(shù)據(jù)未讀入內存,從硬盤讀取后緩存入內存Major (requiring I/O) page faults: 0# 已讀入內存緩存區(qū)的數(shù)據(jù)Minor (reclaiming a frame) page faults: 2451338# 程序自動放棄CPU使用權的次數(shù)Voluntary context switches: 293# 程序被動放棄CPU使用權的次數(shù)Involuntary context switches: 434Swaps: 0# 總的讀寫字符數(shù)File system inputs: 0File system outputs: 6246432Socket messages sent: 0Socket messages received: 0Signals delivered: 0Page size (bytes): 4096Exit status: 0

有了這個工具,下一步就可以愉快的評估不同的軟件、數(shù)據(jù)量所使用的計算資源多少,進而指導電腦裝機了。

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除了监控程序运行时间还能干这个?的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。