gprof

gprof command is not creating proper out.txt

大憨熊 提交于 2019-12-05 07:40:17
First of all I'm running MacOSX 10.7.1. I've installed all properly, Xcode 4 and all the libraries, to work with C lenguage. I'm having troubles running gprof command in shell. I'll explain step by step what I'm doing and the output I'm receiving. Step 1: ~ roger$ cd Path/to/my/workspace ~ roger$ ls Output (Step 1): queue.c queue.h testqueue.c Step 2: ~ roger$ gcc -c -g -pg queue.c ~ roger$ ls Output (Step 2): queue.c queue.h queue.o testqueue.c Step 3: ~ roger$ gcc -o testqueue -g -pg queue.o testqueue.c ~ roger$ ls Output (Step 3): queue.c queue.h queue.o testqueue testqueue.c Step 4: ~

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

半腔热情 提交于 2019-12-05 05:56:00
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 "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -pg") set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -pg") does not allow gprof to demangle the C++ functions. Any ideas? (I am using C++11) Try using: SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER

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

妖精的绣舞 提交于 2019-12-04 23:51:50
I'm running on Mac OSX, version 10.8.5 (Mountain Lion). I have the following simple C++ code. main.cpp : #include <iostream> int main () { std::cout << "Hello world!"<<std::endl; std::cout << "Goodbye world!"<<std::endl; return 0; } I'm trying to get gprof to work on my computer. As the manual suggests, I enter the following two lines into my terminal: g++ -g -pg main.cpp -o a.out ./a.out However this does not generate a gmon.out file as it is supposed to. When I try typing gprof in the terminal, it says: gprof: can't open: gmon.out (No such file or directory) which is to be expected since

Would the time counted in gprof include what is spent in functions that are not profiled?

痴心易碎 提交于 2019-12-04 20:43:38
I now have a project which I want do profiling on, but it used another library which I have no control of. Say if there if such a function: #include <library.h> void function(...) { // do something for (...) { // ... library_function(...); // ... } // do something } Let's assume that library_function is from another static library which is not compiled with profiling enabled. Now if gprof tells me running function took 10s including all its children, will this include the time spent in library_function ? Mike Dunlavey No, because the way gprof works, it samples the program counter, figures out

Any way to specify the location of profile data

ε祈祈猫儿з 提交于 2019-12-04 17:13:14
问题 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 回答1: 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

Which is the most reliable profiling tool gprof or kcachegrind?

两盒软妹~` 提交于 2019-12-04 14:33:26
问题 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? 回答1: 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

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

喜夏-厌秋 提交于 2019-12-04 07:44:13
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 a useful program I'm trying to profile. It's not specific to this trivial test case. (Also in this case gprof says that main() takes more than 100% of the program's running time, which is a pretty stupid bug but not really causing problems for me.) $ cat test.c int main() { int i; for (i=0;i<1000000000;i++); } $ gcc test.c -o test $ time ./test real

Tools for profiling OCaml code

╄→гoц情女王★ 提交于 2019-12-03 23:20:45
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? poorman's profiler is perfectly applicable for OCaml programs. The same idea works out for profiling allocations as well. Never used it but ocamlviz is another option. You can also use ocaml-memprof, a compiler patch ( 3.12.0 and 3.12 1 ) written by Fabrice Le Fessant, that adds memory profiling features to ocaml programs. EDIT Now you have ocp-memprof , an OCaml

Why does my code run slower with multiple threads than with a single thread when it is compiled for profiling (-pg)?

我的梦境 提交于 2019-12-03 21:49:40
I'm writing a ray tracer. Recently, I added threading to the program to exploit the additional cores on my i5 Quad Core. In a weird turn of events the debug version of the application is now running slower, but the optimized build is running faster than before I added threading. I'm passing the "-g -pg" flags to gcc for the debug build and the "-O3" flag for the optimized build. Host system: Ubuntu Linux 10.4 AMD64. I know that debug symbols add significant overhead to the program, but the relative performance has always been maintained. I.e. a faster algorithm will always run faster in both

What are _Unwind_SjLj_Unregister and _Unwind_SjLj_Register?

↘锁芯ラ 提交于 2019-12-03 16:05:38
What are _Unwind_SjLj_Unregister and _Unwind_SjLj_Register? I get them as my top processor time users in my gprof report. google only returns links to people complaining about errors with these two. heres the only part of my report that has times != 0: Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ms/call ms/call name 33.33 0.03 0.03 _Unwind_SjLj_Unregister 22.22 0.05 0.02 _Unwind_SjLj_Register 11.11 0.06 0.01 13886 0.00 0.00 toint(std::string, int) 11.11 0.07 0.01 4380 0.00 0.00 hexlify(std::string) 11.11 0.08 0.01 2994 0.00 0.00 std