Questions tagged [gprof]

gprof is a GNU tool used for code profiling.

To use it you need to compile your code with gcc and the option -pg. Then execute your software; it will create a file named "gmon.out". gprof can analyze this file and provide you with performance information about the execution of your software.

322 questions
174
votes
7 answers

Alternatives to gprof

What other programs do the same thing as gprof?
neuromancer
  • 53,769
  • 78
  • 166
  • 223
49
votes
10 answers

How to profile multi-threaded C++ application on Linux?

I used to do all my Linux profiling with gprof. However, with my multi-threaded application, it's output appears to be inconsistent. Now, I dug this up: http://sam.zoy.org/writings/programming/gprof.html However, it's from a long time ago and in my…
anon
  • 41,035
  • 53
  • 197
  • 293
37
votes
3 answers

How does GCC's '-pg' flag work in relation to profilers?

I'm trying to understand how the -pg (or -p) flag works when compiling C code with GCC. The official GCC documentation only states: -pg Generate extra code to write profile information suitable for the analysis program gprof. You must use this…
Trevor
  • 1,858
  • 4
  • 21
  • 28
34
votes
1 answer

gprof and arguments to executable

when using gprof: $ gprof options [executable-file [profile-data-files...]] [> outfile] if you have options to pass to the executable like: gprof a.out --varfred=32 then gprof assumes that I am passing an invalid option to it, instead of to the…
Thorvaldur
  • 531
  • 2
  • 5
  • 9
33
votes
1 answer

What is -no-pie used for?

I was working on Ubuntu 17.10 with GPROF for some testing with C files, and when I execute with gprof the file generated (gmon.out), compiling and linking with -pg option, I got an empty flat and call graph. However, I found that this is a GCC bug,…
SGodoy
  • 703
  • 1
  • 5
  • 13
33
votes
3 answers

gprof : How to generate call graph for functions in shared library that is linked to main program

I am working on Linux environment. I have two 'C' source packages train and test_train. train package when compiled generates libtrain.so test_train links to libtrain.so and generates executable train-test Now I want to generate a call graph using…
atv
  • 1,950
  • 4
  • 21
  • 26
31
votes
2 answers

How to use gprof with cmake

I have looked at dozens of tutorials for profiling with gprof. I'm trying to work with code for the SMT solver dReal. To build the program, I first installed g++-4.8, Bison, Flex, and Cmake. Then to build dReal, the instructions said to execute the…
Phdetermined
  • 411
  • 1
  • 4
  • 5
29
votes
2 answers

Is it possible to get a graphical representation of gprof results?

I am interested in getting the profiling of some number crunching program. I compiled it with -g and -pg options and linked it and got it gmon.out. After reading the info (plain text) it looks a bit ugly. I wonder if there are some open source tools…
Open the way
  • 26,225
  • 51
  • 142
  • 196
28
votes
2 answers

Alternative to -pg with Clang?

I wish to profile CPU (sample if possible), with as small a performance impact as possible (hence similar to GCC's -pg), binaries compiled with Clang. Is there an alternative that uses instrumentation of the code, or produces output similar to…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
28
votes
7 answers

gprof reports no time accumulated

I'm trying to profile a C++ application with gprof on a machine running OSX 10.5.7. I compile with g++ in the usual way, but using -pg flags, run the application and try to view the call graph with gprof. Unfortunately my call graph contains all…
Daniel
  • 23,365
  • 10
  • 36
  • 34
27
votes
5 answers

List of all function calls made in an application

How can we list all the functions being called in an application. I tried using GDB but its backtrace list only upto the main function call. I need deeper list i.e list of all the functions being called by the main function and the function being…
broun
  • 2,483
  • 5
  • 40
  • 55
27
votes
1 answer

gprof produces empty output

I'm running Ubuntu 16.10 and trying to profile a program using gprof. I compile with the flag -pg and the program is single-threaded. The actual compile commands are: g++ -I. -std=c++11 -Wall -Wextra -O3 -pg -fPIC -Wno-unused-parameter -c -o…
Malin
  • 771
  • 1
  • 7
  • 16
23
votes
2 answers

Saving gmon.out before killing a process

I would like to use gprof to profile a daemon. My daemon uses a 3rd party library, with which it registers some callbacks, then calls a main function, that never returns. I need to call kill (either SIGTERM or SIGKILL) to terminate the daemon.…
user1202136
  • 11,171
  • 4
  • 41
  • 62
20
votes
4 answers

Why does the order of loops in a matrix multiply algorithm affect performance?

I am given two functions for finding the product of two matrices: void MultiplyMatrices_1(int **a, int **b, int **c, int n){ for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) …
kevlar1818
  • 3,055
  • 6
  • 29
  • 43
19
votes
1 answer

Code compiled with profiling flag does not generate gmon.out

I compiled a code with gcc using the profiling flag (-pg), but when I run the program no gmon.out is generated. I compiled a test code -- actually, the one from this question -- to see if the compilation flag & gprof were working and, yes, it…
Brandt
  • 5,058
  • 3
  • 28
  • 46
1
2 3
21 22