gprof

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

若如初见. 提交于 2019-12-09 14:04:13
问题 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

C++ Time measurement of functions

随声附和 提交于 2019-12-08 06:24:05
问题 I need to measure the time of a C++ programs, especially the overall running time of some recursive functions. There are a lot of function calls inside other functions. My first thought was to implement some time measurements functions in the actual code. The problem with gprof is, that it prints out the time of class operators of a datatype, but i only need the infomartion about the functions and "-f func_name prog_name" wont work. So, what is the most common way in science to measure time

Why does gprof occasionally not print number of calls for particular functions?

久未见 提交于 2019-12-07 21:38:27
问题 The application is compiled with -O0 -g -pg and gprof is run with its default settings. 回答1: Check to make sure that all of your modules have the -pg flag. If any one is missing it, you could have these results. 回答2: (self-answer) I believe it was static declarations. 来源: https://stackoverflow.com/questions/4177152/why-does-gprof-occasionally-not-print-number-of-calls-for-particular-functions

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

蹲街弑〆低调 提交于 2019-12-07 02:36:01
问题 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) 回答1: Try using: SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") SET

gprof command is not creating proper out.txt

[亡魂溺海] 提交于 2019-12-07 02:17:58
问题 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

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

一笑奈何 提交于 2019-12-06 18:31:29
问题 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

system(mkdir) hangs in my application

雨燕双飞 提交于 2019-12-06 15:08:44
There is a method in our codebase which used to work fine, but not any more(without any modification to this method): void XXX::setCSVFileName() { //get current working directory char the_path[1024]; getcwd(the_path, 1023); printf("current dir: %s \n",the_path); std::string currentPath(the_path); std::string currentPathTmp = currentPath + "/tmp_"+pathSetParam->pathSetTravelTimeTmpTableName; std::string cmd = "mkdir -p "+currentPathTmp; if (system(cmd.c_str()) == 0) // stops here { csvFileName = currentPathTmp+"/"+pathSetParam->pathSetTravelTimeTmpTableName + ".csv"; } //... } I tried to debug

Why does gprof occasionally not print number of calls for particular functions?

一曲冷凌霜 提交于 2019-12-06 08:27:46
The application is compiled with -O0 -g -pg and gprof is run with its default settings. Check to make sure that all of your modules have the -pg flag. If any one is missing it, you could have these results. (self-answer) I believe it was static declarations. 来源: https://stackoverflow.com/questions/4177152/why-does-gprof-occasionally-not-print-number-of-calls-for-particular-functions

gprof a library - question

青春壹個敷衍的年華 提交于 2019-12-06 02:49:01
问题 I need to gprof a library in our system to examine the function calls and see if we can optimize it any more. Basically, what I have is Executable A which uses a shared Library myLib.so I want to gprof the myLib.so. When I compile myLib.so source using -pg option, it produces a .so file just fine. But, recompiling the Executable A against that library is not producing the *.gmon file for some reason. What needs to be done? Should I link the myLib statically? If so, please tell me how. I am a

Tools for profiling OCaml code

霸气de小男生 提交于 2019-12-05 12:05:25
问题 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? 回答1: poorman's profiler is perfectly applicable for OCaml programs. The same idea works out for profiling allocations as well. 回答2: Never used it but ocamlviz is another option. 回答3: You can also use ocaml-memprof, a compiler patch (3.12.0 and 3.12 1) written by