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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

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

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

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

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

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

type time # 這是bash中的time time 是 shell 關(guān)鍵字# 這是系統(tǒng)的time which time /usr/bin/time

這時(shí)我們通常需要全路徑去調(diào)用,例如

# /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的時(shí)間User time (seconds): 191.97# 系統(tǒng)占用CPU的時(shí)間System time (seconds): 11.18# 用戶額CPU使用率;雖然指定了10個(gè)線程,但只達(dá)到了雙核效率,快了2倍Percent of CPU this job got: 223%# 程序從開始運(yùn)行到結(jié)束的時(shí)間,人為感覺到的運(yùn)行了多久Elapsed (wall clock) time (h:mm:ss or m:ss): 1:30.93 # 下面5項(xiàng)未做統(tǒng)計(jì),都給予了0Average shared text size (kbytes): 0Average unshared data size (kbytes): 0Average stack size (kbytes): 0Average total size (kbytes): 0Average resident set size (kbytes): 0# 該進(jìn)程占用的最大物理內(nèi)存, 2.3GMaximum resident set size (kbytes): 2306644# 數(shù)據(jù)未讀入內(nèi)存,從硬盤讀取后緩存入內(nèi)存Major (requiring I/O) page faults: 0# 已讀入內(nèi)存緩存區(qū)的數(shù)據(jù)Minor (reclaiming a frame) page faults: 2451338# 程序自動(dòng)放棄CPU使用權(quán)的次數(shù)Voluntary context switches: 293# 程序被動(dòng)放棄CPU使用權(quán)的次數(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

有了這個(gè)工具,下一步就可以愉快的評(píng)估不同的軟件、數(shù)據(jù)量所使用的計(jì)算資源多少,進(jìn)而指導(dǎo)電腦裝機(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

  • 總結(jié)

    以上是生活随笔為你收集整理的Time除了监控程序运行时间还能干这个?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

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