Question: Profiling with gprof 1. If you dont have access to a Linux system and want to work on Windows system, Install MinGw. There are two

Profiling with gprof

1. If you dont have access to a Linux system and want to work on Windows

system, Install MinGw. There are two versions of MinGW for 64-bit

machine:

siji

seh

2. Compile your code with gcc. The -pg will enable profiling.

> gcc -g -pg head.h main.c -o executable.exe

3. Run the program. The profiling data will be written to a file called

gmon.out under the current directory.

> executable.exe main.c

4. The above gmon.out file is not readable. We can use gprof to interpret it

and generate a plain txt file.

> gprof executable.exe gmon.out > analysis.txt

From the txt file, we can see the the the running time of each functions.

But there are many ways to visualize the the result. Specifically, for

windows, Gprof2Dot is easy to use. The following two should be installed:

Python for Windows

Graphviz for Windows

Again, add their bin folders to PATH.

5. Run gprof2dot

> python gprof2dot.py -n0.5 -s analysis.txt > analysis.dot

6. Run GraphViz

> dot -Tpng analysis.dot -Gcharset=latin1 -o analysis.png

Reference: http://www.thegeekstuff.com/2012/08/gprof-tutorial

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!