Difference between revisions of "Perf"

From D Wiki
Jump to: navigation, search
(Created page with "=Perf= [https://perf.wiki.kernel.org/index.php/Main_Page Perf] is a performance measurement tool for the Linux kernel. ==Finding Infinite Loops== '''Problem:'''<br/> Your pr...")
 
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
=Perf=
 
 
[https://perf.wiki.kernel.org/index.php/Main_Page Perf] is a performance measurement tool for the Linux kernel.
 
[https://perf.wiki.kernel.org/index.php/Main_Page Perf] is a performance measurement tool for the Linux kernel.
  
Line 11: Line 10:
 
# After a few seconds of recording, kill perf with Ctrl+C
 
# After a few seconds of recording, kill perf with Ctrl+C
 
# Run '''perf report'''. The report should clearly identify which functions are being executed in the loop.
 
# Run '''perf report'''. The report should clearly identify which functions are being executed in the loop.
 +
 +
[[Category:HowTo]]

Latest revision as of 10:16, 14 November 2014

Perf is a performance measurement tool for the Linux kernel.


Finding Infinite Loops

Problem:
Your program is in an infinite loop. You're not sure how you triggered it, and worry that if you kill the program you may not be able to trigger this bug easily. You want to know where the infinite loop is.

Solution:

  1. Use the -p option of perf record, supplying the process id of your program. This will instruct perf to attach to your currently-running process.
    perf record -p $(pidof myprogram)
  2. After a few seconds of recording, kill perf with Ctrl+C
  3. Run perf report. The report should clearly identify which functions are being executed in the loop.