gprof

Any way to specify the location of profile data

六眼飞鱼酱① 提交于 2019-12-03 10:53:35
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 jscoot Too badly, the environment variable GMON_OUT_PREFIX is not documented in the glibc. I got the following information from the web and tested on my machine. if you set the environment variable GMON_OUT_PREFIX , then the output file is named as ${GMON_OUT_PREFIX}.[PID] , the pid is the id of the profiled process. For example: GMON_OUT_PREFIX=mygmon; gcc -o foo -pg foo.c the gmon out file is: mygmon.12345 , assuming the

gcc: undefined reference to _mcount (gprof instrumentation)

*爱你&永不变心* 提交于 2019-12-03 10:19:35
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? (Solaris 10 SPARC Platform) Are you both compiling each object file and linking the final executable using the '-pg' flag? 来源: https://stackoverflow.com/questions/4603298/gcc-undefined-reference-to-mcount-gprof-instrumentation

Which is the most reliable profiling tool gprof or kcachegrind?

佐手、 提交于 2019-12-03 09:05:10
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 results. Does it mean one of them is not reliable? What would yo do here? gprof is actually quite primitive. Here's what it does. 1) It samples the program counter at a constant rate and records how many samples land in each function (exclusive time). 2) It counts how many times any function A calls any function B. From that it can find out how many

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

北战南征 提交于 2019-12-03 06:47:45
问题 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 Additional Command-Line Tools (mac). gprof:Produces execution profiles based on an execution analysis of a program. I installed command line tools, so other command line tools such as otool and atos are available. I googled to find this page (https:

Get gprof to profile based on wall-clock time?

删除回忆录丶 提交于 2019-12-03 06:46:01
My understanding is that by default gprof takes into account CPU time. Is there a way to get it to profile based on wall-clock time? My program does a lot of disk i/o, so the CPU time it uses only represents a fraction of the actual execution time. I need to know which portions of the disk i/o take up the most time. dronnix You can measure wall-clock time by using profiler from google-perftools. To switch google profiler to wall-clock mode, set the environment variable CPUPROFILE_REALTIME=1. Mike Dunlavey gprof won't do this. Look at this . And this. In a nutshell: Under gdb , get it running

Time Sampling Problems with gprof

冷暖自知 提交于 2019-12-01 19:38:58
I am attempting to profile some c++ code, compiled with g++ including the option -pg, using gprof. However, in spite of the fact that the program takes 10-15 minutes to run on my computer (with the CPU maxed out), the % time, cumulative seconds and self seconds columns of the table produced by gprof are entirely 0.00s! The calls column contains correct looking data, for example over 150,000 calls to a basic function. Here is a sample of the data collected: % cumulative self self total time seconds seconds calls Ts/call Ts/call name 0.00 0.00 0.00 156012 0.00 0.00 perm::operator[](int) const 0

What is function __tcf_0? (Seen when using gprof and g++)

Deadly 提交于 2019-12-01 15:57:41
问题 We use g++ 4.2.4 and I'm trying to track down some performance problems in my code. I'm running gprof to generate the profile, and I'm getting the following "strangeness" in that the most expensive function is __tcf_0: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ms/call ms/call name 40.00 0.04 0.04 1 40.00 95.00 __tcf_0 This function then appears to calls most of my user functions (ie. it is the one that's called from main). The nearest

Gprof: specific function time [duplicate]

让人想犯罪 __ 提交于 2019-12-01 12:09:13
This question already has an answer here: Function execution time 2 answers I want to find out the time spent by a particular function in my program. FOr that purpose, I am making use of gprof. I used the following command to get the time for the specific function but still the log file displays the results for all the functions present in the program. Please help me in this regard. gprof -F FunctionName Executable gmon.out>log Basile Starynkevitch You are nearly repeating another question about function execution time . As I answered there , there is a difficulty (due to hardware!) to get

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

你离开我真会死。 提交于 2019-12-01 00:55:55
问题 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 written. gcc is 4.4.7. OS is centos 6. My program was launched by a hand-rolled Perl daemon using fork/exec. I've verified that the CWD is my home directory, and that it's writeable, by having the daemon execute touch foo just before exec'ing my target

Using gprof with pthreads

强颜欢笑 提交于 2019-11-30 13:29:58
问题 Can gprof be used to profile a multi-threaded program that uses pthreads? That is, will its output include the time used in all the threads? 回答1: Yes, it is possible with the help of a workaround described here. 回答2: Have you considered pstack? It works fine with multiple threads, and it is good for finding performance problems by the stackshot method. gprof is what it is, but chances are you can do better. 来源: https://stackoverflow.com/questions/922475/using-gprof-with-pthreads