linux perf使用經驗之一二__linux

來源:互聯網
上載者:User
linu perf使用經驗之一二

perf是一個非常強大的工具,之前聽說但一直沒有怎麼用過。現在記錄下來以便事後尋找。 編譯

除了從包管理器中安裝,還可以從原始碼裡直接編譯。

非常簡單,clone好核心原始碼.

cd linux/tools/perfmake

怎麼樣, so easy吧。 開跑

哥是個急性子,別的先不想管,先看看這個東西能跑成什麼樣子。估計各位看官也是差不多,那咱就先跑幾個來先看看。 看看程式總體情況

假如你有個程式,想看看這個程式有沒有可以最佳化的點。那就要先看看這個程式的已耗用時間都是分配在哪些函數上了。然後在做進一步的最佳化。

perf stat ./your_program Performance counter stats for './your_program':        254.098794 task-clock                #    0.997 CPUs utilized                          21 context-switches          #    0.083 K/sec                                   6 cpu-migrations            #    0.024 K/sec                                  86 page-faults               #    0.338 K/sec                         774,758,136 cycles                    #    3.049 GHz                           554,772,168 stalled-cycles-frontend   #   71.61% frontend cycles idle           26,055,211 stalled-cycles-backend    #    3.36% backend  cycles idle          550,801,917 instructions              #    0.71  insns per cycle                                                     #    1.01  stalled cycles per insn       110,128,040 branches                  #  433.406 M/sec                               7,007 branch-misses             #    0.01% of all branches               0.254960900 seconds time elapsed

具體每個細節暫時搞不懂,先放著。知道是做什麼的一個大概,以後用的時候再來看。 看看系統總體情況

有時候是整個系統出現了瓶頸,想要調試。那就要先看看整體系統到底哪裡啟動並執行比較多。

perf top================================================================================list the processes with their cpu utilization  6.92%  libc-2.13.so                      [.] 0x0007aa67  2.99%  perf                              [.] symbols__insert  2.93%  perf                              [.] symbol_filter  2.79%  libxul.so                         [.] 0x0088efc3  2.68%  [kernel]                          [k] aes_decrypt  2.14%  libflashplayer.so                 [.] 0x003442f4  1.86%  perf                              [.] rb_next  1.54%  chromium-browser                  [.] 0x01363b5f
perf的事件構成

留著看看,反正也不懂

所有perf能夠捕捉的事件可以運行

perf list

來得到。 Reference

Linux Perf Examples 感覺這個講的還比較全面

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.