linux poison RSS
linux poison Email

How to Profile Applications under Linux - perf

The purpose of application profiling is to check whether an application, which is being developed, works as it is supposed to and to assist the developers in improving the application.

Profiling Prerequisites:
Profiling an application involves the following steps:
 * Profiling applications on remote hosts requires the installation of the Agent Controller. Profiling local applications requires no additional install or setup.
 * Launching an application
 * Specifying profiling criteria
 * Using profiling views to analyze data
 * Save profiling data or resources if you expect to use them again 

Perf is a profiler tool for Linux 2.6+ based systems that abstracts away CPU hardware differences in Linux performance measurements and presents a simple command-line interface. Perf is based on the perf_events interface exported by recent versions of the Linux kernel.

Perf Installation:
Open the terminal and type following command to install Perf under Ubuntu:
sudo apt-get install linux-tools-common
Using Perf:
The perf tool offers a rich set of commands to collect and analyze performance and trace data. The command line usage is reminiscent of git in that there is a generic tool, perf, which implements a set of commands: stat, record, report and more, check man pages for more options.

To profile an application, you have to record information about an execution, for that, you just have to use perf record option : This is will generate a file call - perf.data in the current directory
perf record firefox
After the completion of execution, you can use below command to view and analysis the performance of your application:
perf report

The user-space perf tools present a simple to use interface with commands like
 * perf stat: obtain event counts
 * perf record: record events for later reporting
 * perf report: break down events by process, function, etc.
 * perf annotate: annotate assembly or source code with event counts
 * perf top: see live event count


0 comments:

Post a Comment

Related Posts with Thumbnails