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
6
votes
2 answers

Interpreting gprof output with

I am trying to find a performance issue in my program and thus instrumented the code with profiling. gprof creates a flat profile like this: Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total …
Philipp
  • 11,549
  • 8
  • 66
  • 126
6
votes
3 answers

Excluding a function from gprof results

I want to exclude some functions from the output generated by gprof. In other words, I do not want them to be included when calculating percentage time spent by each function during execution. I read at one place -E option can be used. However I'm…
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
6
votes
4 answers

Profiling partial programs in Linux

I have a program in which significant amount of time is spent loading and saving data. Now I want to know how much time each function is taking in terms of percentage of the total running time. However, I want to exclude the time taken by loading…
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
6
votes
2 answers

Enable and disable gprof at runtime?

I wonder if there's any API within gprof to enable and disable profiling at runtime by the monitored application. I'm interested on disabling the profiling of certain parts of the code and enabling it to focus on those that are interesting to me. I…
Harald
  • 3,110
  • 1
  • 24
  • 35
6
votes
1 answer

How can I profile c++ using gcc/gprof with "-fomp" and "-pg -fprofile-create"?

I'm confused as to whether it is possible to compile/link a profiling build for gprof using gcc with OpenMP enabled. The gcc docs seem silent on the matter, as far as my google searches indicated. Experimentally, adding just the -fomp switch causes…
justinzane
  • 1,897
  • 1
  • 26
  • 38
6
votes
2 answers

Why is gccgo slower than gc in that particular case?

I'm sure everyone knowing golang knows that blog post here. Reading it again, I wondered if using gccgo instead of go build would increase the speed a bit more. In my typical use case (scientific computations), a gccgo-generated binary is always…
user1940040
6
votes
3 answers

Profile single function in gprof

Is it possible to use gprof to line-profile a single function in C++? Something like: gprof -l -F function_name ... , which does not seem to work.
Bi.
  • 1,846
  • 8
  • 25
  • 34
5
votes
7 answers

Speeding up virtual function calls in gcc

Profiling my C++ code with gprof, I discovered that a significant portion of my time is spent calling one virtual method over and over. The method itself is short and could probably be inlined if it wasn't virtual. What are some ways I could speed…
Wayne Kao
  • 8,125
  • 5
  • 30
  • 25
5
votes
2 answers

Which is the most reliable profiling tool gprof or kcachegrind?

Profiling some C++ number crunching code with both gprof and kcachegrind gives similar results for the functions that contribute most to the execution time (50-80% depending on input) but for functions between 10-30% both these tools give different…
Open the way
  • 26,225
  • 51
  • 142
  • 196
5
votes
1 answer

How do I get meaningful results from gprof on an MPI code?

I am optimising an MPI code and I am working with Gprof. The problem is that the results I obtained are completely unreasonable. My workflow is the following: compiling the code adding -pg as a compilation flag. running the code mpirun -np Nproc…
John Snow
  • 85
  • 4
5
votes
3 answers

Why does gprof significantly underestimate the program's running time?

I have this program that takes 2.34 seconds to run, and gprof says it only takes 1.18 seconds. I've read answers elsewhere suggesting that gprof can get it wrong if e.g the program is I/O bound, but this program clearly isn't. This also happens for…
Angus
  • 1,350
  • 10
  • 15
5
votes
1 answer

Why would a generated gmon.out file contain no data?

I've compiled a program using -pg switch and linked using the -pg switch. When my program is executed a file "gmon.out" is produced. However after running gprof on the file, there is no data other than the standard information explaining the data…
NeomerArcana
  • 1,978
  • 3
  • 23
  • 50
5
votes
2 answers

Change the name of gmon.out file when compiling with -pg

Is it possible to change the default name of the file gmon.out, which is created when the profile flag (-pg) is set when compiling with gcc, to, for example, [executable name].gmon.out? I need this because I have more than one executables, which are…
Emiswelt
  • 3,909
  • 1
  • 38
  • 56
5
votes
3 answers

How to use gprof to profile a daemon process without terminating it gracefully?

Need to profile a daemon written in C++, gprof says it need to terminate the process to get the gmon.out. I'm wondering anyone has ideas to get the gmon.out with ctrl-c? I want to find out the hot spot for cpu cycle
Jingle
  • 53
  • 1
  • 6
5
votes
1 answer

C++ main only uses ~20% time says gprof

I tried profiling my C++ program with gprof. The program itself ran for about 53 seconds, so I dont understand why it says, main only ran for about 8.29 seconds. Any explanation on this? Here is an excerpt: index % time self children called …
Martin Lauridsen
  • 341
  • 4
  • 12