gprof

Why gprof underestimates total time

[亡魂溺海] 提交于 2020-01-16 04:56:06
问题 I have CPU bound process which runs for 5 hours (CPU time by using getrusage() ) I tried to profile it by gprof. The total time main() took is only about 5000s. My program is CPU bound, it has some disc IO but it is not that significant. Profile interrupts are on, and my process in not multithreaded. 回答1: It only samples in routines it knows about. You calling new ? That's going to spend time in places where gprof doesn't go. BTW, if you're looking for ways to save some time (after 5 hours I

Faster way to compute likelihood of sequence?

跟風遠走 提交于 2020-01-04 06:15:16
问题 This is my second question of previous one Faster way to do multi dimensional matrix addition? After follow the advice of @Peter Cordes i vectorize my code and now the speed has been up by 50X. Then i again did the gprof and found this function is taking most of the time. Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls Ts/call Ts/call name 69.97 1.53 1.53 cal_score(int, std::string, int const*, int, double) double cal_score(int l, string seq, const

C++的性能优化实践

佐手、 提交于 2020-01-04 03:40:59
优化准则: 1. 二八法则:在任何一组东西中,最重要的只占其中一小部分,约20%,其余80%的尽管是多数,却是次要的;在优化实践中,我们将精力集中在优化那20%最耗时的代码上,整体性能将有显著的提升;这个很好理解。函数A虽然代码量大,但在一次正常执行流程中,只调用了一次。而另一个函数B代码量比A小很多,但被调用了1000次。显然,我们更应关注B的优化。 2. 编完代码,再优化;编码的时候总是考虑最佳性能未必总是好的;在强调最佳性能的编码方式的同时,可能就损失了代码的可读性和开发效率; 工具: 1 Gprof 工欲善其事,必先利其器。对于Linux平台下C++的优化,我们使用gprof工具。gprof是GNU profile工具,可以运行于linux、AIX、Sun等操作系统进行C、C++、Pascal、Fortran程序的性能分析,用于程序的性能优化以及程序瓶颈问题的查找和解决。通过分析应用程序运行时产生的“flat profile”,可以得到每个函数的调用次数,消耗的CPU时间(只统计CPU时间,对IO瓶颈无能为力),也可以得到函数的“调用关系图”,包括函数调用的层次关系,每个函数调用花费了多少时间。 2. gprof使用步骤 1) 用gcc、g++、xlC编译程序时,使用-pg参数,如:g++ -pg -o test.exe test.cpp

What is _IO_wfile on a gprof output of a fortran code?

我与影子孤独终老i 提交于 2020-01-03 15:56:44
问题 I have some fortran code compiled with intel fortran compiler ifort. When I do a profile test with gprof, I get that most of the time is used in IO operations, I think finding the end of the files, but I can no find any more documentation on this: index % time self children called name <spontaneous> [1] 20.6 0.07 0.00 _IO_wfile_seekoff [1] ----------------------------------------------- <spontaneous> [2] 20.6 0.07 0.00 sforcepf_ [2] ----------------------------------------------- <spontaneous

system(mkdir) hangs in my application

故事扮演 提交于 2020-01-02 21:47:49
问题 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

How to build-in gprof support to a program built with SCons?

梦想与她 提交于 2020-01-02 02:53:07
问题 Greetings, Here is my SConstruct file: env = Environment() env.Append(CCFLAGS=['-g','-pg']) env.Program(target='program1', source= ['program1.c']) Also here is the output of the compilation: scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... gcc -o program1.o -c -g -pg program1.c gcc -o program1 program1.o scons: done building targets. As you can see I pass the "-pg" option to the build environment. After I build, I run the program to

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

情到浓时终转凉″ 提交于 2020-01-01 19:52:11
问题 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

What are _Unwind_SjLj_Unregister and _Unwind_SjLj_Register?

天涯浪子 提交于 2020-01-01 05:40:29
问题 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

Inaccuracy in gprof output

送分小仙女□ 提交于 2019-12-30 05:24:26
问题 I am trying to profile a c++ function using gprof, I am intrested in the %time taken. I did more than one run and for some reason I got a large difference in the results. I don't know what is causing this, I am assuming the sampling rate or I read in other posts that I/O has something to do with it. So is there a way to make it more accurate and generate somehow almost constant results? I was thinking of the following: increase the sampling rate flush the caches before executing anything use

gprof shows every function as 100%

白昼怎懂夜的黑 提交于 2019-12-25 02:39:17
问题 I'm using a modified auditd package, and linked gprof with it. But from the output of gprof XX | gprof2dot | dot -Tpng output.png , all functions are 100% usage, so I cannot tell who's consuming most of the CPU resources. (Right click on the image to have a full view) Any ideas? Is that normal, and most importantly, how should I know which function consumes most CPU? P.S: original gprof output http://pastie.org/8546568 回答1: At the top of the flat profile (in the pastie.org link) is the