Search code examples
performanceunixtestingjobs

How do I see a Unix Job's performance (execution time and cpu resource) after execution?


I have an incoming task that tells me to do performance testing on a unix job. I would like to know if there's something in UNIX that would tell me of a job's performance (execution time and cpu resource)? I plan to do a before and after comparison.


Solution

  • You can use linux profile tool perf, eg:

    perf stat ls
    

    In my computer:

     Performance counter stats for 'ls':
    
          2.066571 task-clock                #    0.804 CPUs utilized          
                 1 context-switches          #    0.000 M/sec                  
                 0 CPU-migrations            #    0.000 M/sec                  
               267 page-faults               #    0.129 M/sec                  
         2,434,744 cycles                    #    1.178 GHz                     [57.78%]
         1,384,929 stalled-cycles-frontend   #   56.88% frontend cycles idle    [52.01%]
         1,035,939 stalled-cycles-backend    #   42.55% backend  cycles idle    [98.96%]
         1,894,339 instructions              #    0.78  insns per cycle        
                                             #    0.73  stalled cycles per insn
           370,865 branches                  #  179.459 M/sec                  
            14,280 branch-misses             #    3.85% of all branches        
    
       0.002569026 seconds time elapsed