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
18
votes
3 answers

How to profile from the command line on Mac OS X?

I'm trying to profile C/C++ code on Mac OS X using command line tools, I use -pg option with gcc to run gprof on Linux, but I can't seem to find the gprof on Mac even though I have a description in this page: Additional Command-Line Tools (iOS) or…
prosseek
  • 182,215
  • 215
  • 566
  • 871
17
votes
2 answers

How exactly does gprof work?

This is something of a bloated question, so I apologize ahead of time. I'm curious about how gprof works on a low technical level. I understand it's done by timers, but then why does the executable need to be specially compiled to be profiled? Does…
alexgolec
  • 26,898
  • 33
  • 107
  • 159
17
votes
1 answer

gcc: undefined reference to _mcount (gprof instrumentation)

When compiling my c++ sources with the -pg option to inject gprof profile instrumentation code the compile fails with the undefined reference to _mcount error. Without this option everything compiles (and runs) fine. What is wrong in my case?…
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
16
votes
3 answers

Tools for profiling OCaml code

Is anybody aware of programs for profiling OCaml code apart from using the -p option while compilation and then using gprof? I am asking this question in order to check if the sampling time of 0.01 second can be lowered further?
maths-help-seeker
  • 946
  • 1
  • 10
  • 30
16
votes
4 answers

Any way to specify the location of profile data

The default the profile file is from the executable is run and the file is called gmon.out. Is there any way to specify a new location? I'm using gcc 3.4.6 on i386/linux2.6
hhafez
  • 38,949
  • 39
  • 113
  • 143
16
votes
3 answers

How to install gprof on OS X

I'm trying to use gprof to profile a c++ application I've written but I can't figure out for the life of me how to download and install it. I've googled everything I can think of and can't even find a download link. Someone please help!
zaloo
  • 879
  • 3
  • 13
  • 27
14
votes
1 answer

How to set flags of g++ using cmake such that gprof can demangle?

How do I set the gprof flags for the compiler and linker of GNU g++ in a CMakeLists.txt? My current approach, set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -pg") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO…
Max Flow
  • 607
  • 7
  • 15
14
votes
1 answer

gmon.out isn't created when I compile with -pg flag with g++

I'm running on Mac OSX, version 10.8.5 (Mountain Lion). I have the following simple C++ code. main.cpp: #include int main () { std::cout << "Hello world!"<
nukeguy
  • 416
  • 1
  • 7
  • 20
13
votes
1 answer

GCC gprof line-by-line error "somebody miscounted"

I would like to use gcc's gprof line-by-line profiling. But after compiling my program, running it and executing gprof -l binary_name I get messages like: gprof: somebody miscounted: ltab.len=9403 instead of 9391 gprof binary_name runs without…
Agade
  • 505
  • 6
  • 18
13
votes
9 answers

How to profile a continuously running server running on FreeBSD

Possible Duplicate: Saving gmon.out before killing a process I'm trying to profile a server (source code available to me. c-code) on Linux environment. This server runs continuously like a web server. I'm trying to use gprof to profile the…
Srikanth
  • 11,564
  • 3
  • 23
  • 28
12
votes
2 answers

gprof vs cachegrind profiles

While trying to optimize a code, I'm a bit puzzled by differences in profiles produced by kcachegrdind and gprof. Specifically, if I use gprof (compiling with the -pg switch, etc), I have this: Flat profile: Each sample counts as 0.01 seconds. % …
ev-br
  • 24,968
  • 9
  • 65
  • 78
11
votes
0 answers

BFD: Dwarf Error: Could not find abbrev number 3699

I have installed MinGWDistro 15.0 in my computer. And when I run this in cmd g++ "snackstore.cpp" -o "snackstore.exe" -g -pg snackstore.exe gprof.exe "snackstore.exe" gmon.out > gmon.txt I get this error BFD: Dwarf Error: Could not find abbrev…
TO_GA
  • 145
  • 3
  • 9
10
votes
4 answers

Profiling C code on Windows when using Eclipse

I know I can profile my code with gprof and kprof on Linux. Is there a comparable alternative to these applications on Windows?
Pieter
  • 31,619
  • 76
  • 167
  • 242
10
votes
4 answers

gmon.out is not written after compiling with gcc -pg -g

Compiled a C++ program using gcc -pg -g (at least, those are the args I gave in the Makefile; don't have any hard evidence of what command was executed). Program ran to normal completion with CWD set to my home directory. No gmon.out file…
Chap
  • 3,649
  • 2
  • 46
  • 84
10
votes
1 answer

Profile Generate vs PG

Can anybody explain to me the difference between profile-generate and the pg options?
Laser
  • 6,652
  • 8
  • 54
  • 85
1
2
3
21 22