Gprof is a performance analysis tool for Unix applications. It used a hybrid of instrumentation Another implementation was written as part of the GNU project for GNU GPROF output consists of two parts: the flat profile and the call graph. Gprof is a profiling program which collects and arranges statistics on your lly, it looks Write hate-mail to gnu (but don’t tell them I told you to). If you are a programmer, who writes code in C, Pascal, or Fortran77 programming language and uses Linux as the development platform, youll be glad to.

Author: Meztill Taurr
Country: China
Language: English (Spanish)
Genre: Spiritual
Published (Last): 25 March 2015
Pages: 267
PDF File Size: 9.86 Mb
ePub File Size: 20.34 Mb
ISBN: 271-4-52138-817-3
Downloads: 85902
Price: Free* [*Free Regsitration Required]
Uploader: Fenrijas

There’s no doubt that testing is an integral and one of the most important aspects of the software gpro process. And by testing, we don’t mean just testing the code for bugs – of course, bug detection is important as nobody would want their software to be buggy – performance of the code also equally matters these days. If broken down to the last bit, performance testing effectively tests how much time a particular piece of code – say a function – is consuming.

How to install and use profiling tool Gprof on Linux

As is usually the case, a function or a group of functions may correspond to one of the many features of a software. So, if through performance prifiler, we can enhance the performance of these functions in code, the overall performance of the software becomes better. In this tutorial, we’ll be discussing the details of how you can download, install, and use this tool. Before we move ahead, please note that all the examples and instructions mentioned in this tutorial have been tested on Ubuntu So, vnu exactly is Gprof?


According to the tool’s official documentation, it gives users an execution profile of their C, Pascal, or Fortran77 programs. What Gprof basically does is, it calculates the amount of time spent in each routine or function. Cycles are discovered, and calls into a cycle are made to share the time of the cycle. If all this sounds a bit confusing at this point especially the part in quotesdon’t worry, as we’ll make things clear through an example.

First check whether or not the tool is already installed on your system. To do this, just run the following command in a terminal. Else you can install it using the following command:. Needless to say, the best way to understand a tool like Gprof is through a practical example. So, we’ll start off with a C language program, which we’ll be profiling through Gprof. Now, moving on, the next step is to compile this code using gcc.

Note that ideally I would have compiled the above code using the following command:.

But since we’ve to profile the code using Gprof, I’ll have to use the -pg command line option provided by the gcc compiler. So, the command becomes:. The next thw is to launch that executable. Here’s how I launched the binary in my case: Once the command is executed, you’ll see that a file named gmon.

It is this file which contains all the information that the Gprof tool requires to produce a human-readable profiling data. So, tje use the Gprof tool in the following way:.


Here’s what the man page of Gprof says about information under these two sections:. Armed with this information, now you’ll be in a better position to understand the data present in your profiling output file profile-data. Here’s the flat profile in my case:. If you’re wondering about the source of above screenshots, let me tell you that all this information is there in the output file that contains the profiling information, including flat profile and call graph.

In case you want this information to be omitted from the output, you can use the -b option provided by Gprof. However, whatever we’ve covered here should be enough to get you started.

In case you already use Gprof, and want to share something related to the tool with everyone here, just drop in a comment below. This feature is only available to subscribers. Get your subscription here. Log in or Sign up.

How to install and use profiling tool Gprof on Linux

Reduce your monitoring cost, not your coverage. Comprehensive, affordable, and easy-to-use APM and infrastructure monitoring.

On this page What is Gprof? Download and Install Gprof Gprof Usage. Your name or email address: Do you already have an account? No, create an account now. Yes, my password is: