Saturday, December 13, 2014

用 perf 追蹤系統狀態

Ubuntu 上的安裝方式是安裝 linux-tools,不過我的機器上是安裝 linux-tools-lts-raring
先從比較簡單的 stat,基本的用法很簡單,後面接指令就可以了:
perf stat ls -al
這樣會出現基本的執行狀況,像是這樣:
 Performance counter stats for 'ls -al':

         11.236723 task-clock                #    0.703 CPUs utilized          
               341 context-switches          #    0.030 M/sec                  
                 0 cpu-migrations            #    0.000 K/sec                  
               453 page-faults               #    0.040 M/sec                  
         8,186,524 cycles                    #    0.729 GHz                    
    stalled-cycles-frontend 
    stalled-cycles-backend  
        10,366,309 instructions              #    1.27  insns per cycle        
         2,122,560 branches                  #  188.895 M/sec                  
            36,979 branch-misses             #    1.74% of all branches        

       0.015977493 seconds time elapsed
更複雜的用法在 Tutorial 那篇文章裡面有說明。

https://blog.gslin.org/archives/2014/12/08/5417/%E7%94%A8-perf-%E8%BF%BD%E8%B9%A4%E7%B3%BB%E7%B5%B1%E7%8B%80%E6%85%8B/

No comments: