gprof

Interpreting profiler log for STL based code

笑着哭i 提交于 2019-12-13 06:08:01
问题 I did a generalization a an algorithm implementation. Now, the new implementation runs more than 100 times slower than the old one. My guess is that the source unnecessary use of inefficiency is implicit copy constructors that I somehow introduced. I tried to profile the code, but I get a lot of data that I do not understand. Do I really need to know STL internals to be able to profile STL based code? Snippet of the flat profile: Flat profile: Each sample counts as 0.01 seconds. % cumulative

Get gprof to profile based on wall-clock time?

烂漫一生 提交于 2019-12-12 07:35:13
问题 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. 回答1: 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. 回答2

Automating the profling of C program using GPROF

和自甴很熟 提交于 2019-12-12 00:23:43
问题 I am profiling a matrix multiplication C program using gprof. That C program has a general structure like this; int main() { int n; printf("enter size of square matrices"); scanf("%d", &n); data(matM); //fill matrices with n x n random data data(matN); // this is unoptimized algo matUnopt(int *matM, int *matN, int *MatOut, int size); // this is optimized algo matOpt(int *matM, int *matN, int *MatOut, int size); return(0); } Now at present how I am profiling is: I run my executable mat, give

How to profile an EXE and the DLLs it loaded at the same time?

六月ゝ 毕业季﹏ 提交于 2019-12-11 20:17:19
问题 I'm using the MinGW GCC compiler on Windows. If I add -pg switch to the compiler I can generate both the EXE and the DLL with profile data. The gmon.out is generated. But the problem is that when I use gprof myprogram.exe gmon.out I get no profile output (other than the table headings and other text). gprof mydll.dll gmon.out I get the output for that particular DLL only but not for the main exe. Maybe both the exe and the dll wanted to generate the same file and the dll won. The goal is

Pushing in min heap with std::priority_queue is the bottleneck

≯℡__Kan透↙ 提交于 2019-12-11 12:08:30
问题 Something faster than std::priority_queue as a min heap? The original question is here. You can resolve the names generated by grpof with the demangler. With the help of the users there, I came to a conclusion, where this block of code (that I expect to get executed much more times than I will perform a pop): /** * Min_heap is actually a std::priority_queue, * with std::greater as a parameter. */ typedef std::priority_queue<std::tuple<float, int, int>, std::vector<std::tuple<float, int, int>

gprof not displaying time i e it is displaying 0.0% time even if it is taking more than 20 min?

旧城冷巷雨未停 提交于 2019-12-11 09:18:37
问题 I am new to gprof, this is my program, #include<stdio.h> int somefunc(int n) { int i,j; for(i=1;i<=n;i++){ for(j=1;j<=i;j++){ printf("%d\t",j); } printf("\n"); } } int somefunc1(int n) { int i,j; for(i=n;i>=1;i--){ for(j=i;j>=1;j--){ printf("%d\t",j); } printf("\n"); } } int main() { printf("Hello\n"); int n; printf("enter n value\n"); scanf("%d",&n); somefunc(n); printf("another\n\n"); somefunc1(n); printf("another\n") ; } and i tried this, gcc -pg program.c ./a.out gprof a.out gmon.out and

gcc gprof/gcov/other - how to get sequence of function calls/exits + control flow statements

给你一囗甜甜゛ 提交于 2019-12-11 05:06:44
问题 BACKGROUND We have testers for our embedded GUI product and when a tester declares "test failed", sometimes it's hard for us developers to reproduce the exact problem because we don't have the exact trace of what happened. We do currently have a logging framework but us devs have to manually input those logging statements in the code which is fine . . . except when a hard-to-reproduce bug occurs and we didn't have a log statement at the 'right' location and then when we re-build, re-run the

how to use gprof in Linux?

帅比萌擦擦* 提交于 2019-12-11 04:27:38
问题 I have a C code in a file test.c .I have to profile it using grof .I have used the following commands to do so. gcc -p -o result test.c ./result gprof result A section of the output looks as follows: `Flat profile: Each sample counts as 0.01 seconds. no time accumulated % cumulative self self total time seconds seconds calls Ts/call Ts/call name` The problem is no matter what complex or easy program I use each sample count doesn't change from 0.01 seconds.Why is that and no time is being

Using gprof with sockets

萝らか妹 提交于 2019-12-10 14:35:51
问题 I have a program I want to profile with gprof. The problem (seemingly) is that it uses sockets. So I get things like this: ::select(): Interrupted system call I hit this problem a while back, gave up, and moved on. But I would really like to be able to profile my code, using gprof if possible. What can I do? Is there a gprof option I'm missing? A socket option? Is gprof totally useless in the presence of these types of system calls? If so, is there a viable alternative? EDIT: Platform: Linux

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

笑着哭i 提交于 2019-12-09 18:20:41
问题 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.)