gprof

Confusing gprof output

佐手、 提交于 2019-11-30 07:52:54
I ran gprof on a C++ program that took 16.637s , according to time() , and I got this for the first line of output: % cumulative self self total time seconds seconds calls s/call s/call name 31.07 0.32 0.32 5498021 0.00 0.00 [whatever] Why does it list 31.07% of time if it only took .32 seconds? Is this a per-call time? (Wouldn't that be self s/call?) This is my first time using gprof , so please be kind :) Edit: by scrolling down, it appears that gprof only thinks my program takes 1.03 seconds. Why might it be getting it so wrong? Jesse Beder The bottleneck turned out to be in file I/O (see

Alternative to -pg with Clang?

ぃ、小莉子 提交于 2019-11-30 06:13:12
I wish to profile CPU (sample if possible), with as small a performance impact as possible (hence similar to GCC's -pg ), binaries compiled with Clang. Is there an alternative that uses instrumentation of the code, or produces output similar to gprof? Matt Joiner I received a good answer on the Clang mailing list . To summarize, the use of Google Performance Tools was the best fit. 来源: https://stackoverflow.com/questions/3769057/alternative-to-pg-with-clang

Profiling C code on Windows when using Eclipse

旧城冷巷雨未停 提交于 2019-11-30 04:21:03
问题 I know I can profile my code with gprof and kprof on Linux. Is there a comparable alternative to these applications on Windows? 回答1: Commercial software: Rational Quantify (expensive, slow, but very detailed) AQTime (less expensive, less slow, a bit detailed) Free software: Very sleepy (www.codersnotes.com) Luke StackWalker (lukestackwalker.sourceforge.net) These commercial alternatives change the compiled code by 'instrumenting' (adding instructions) to it and perform the timing withing the

Why does the order of loops in a matrix multiply algorithm affect performance? [duplicate]

匆匆过客 提交于 2019-11-30 03:55:14
This question already has an answer here: Why does the order of the loops affect performance when iterating over a 2D array? 7 answers I am given two functions for finding the product of two matrices: void MultiplyMatrices_1(int **a, int **b, int **c, int n){ for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) c[i][j] = c[i][j] + a[i][k]*b[k][j]; } void MultiplyMatrices_2(int **a, int **b, int **c, int n){ for (int i = 0; i < n; i++) for (int k = 0; k < n; k++) for (int j = 0; j < n; j++) c[i][j] = c[i][j] + a[i][k]*b[k][j]; } I ran and profiled two executables

gprof : How to generate call graph for functions in shared library that is linked to main program

旧城冷巷雨未停 提交于 2019-11-30 00:07:30
I am working on Linux environment. I have two 'C' source packages train and test_train. train package when compiled generates libtrain.so test_train links to libtrain.so and generates executable train-test Now I want to generate a call graph using gprof which shows calling sequence of functions in main program as well as those inside libtrain.so I am compiling and linking both packages with -pg option and debugging level is o0. After I do ./train-test , gmon.out is generated. Then I do: $ gprof -q ./train-test gmon.out Here, output shows call graph of functions in train-test but not in

Confusing gprof output

落花浮王杯 提交于 2019-11-29 10:23:20
问题 I ran gprof on a C++ program that took 16.637s , according to time() , and I got this for the first line of output: % cumulative self self total time seconds seconds calls s/call s/call name 31.07 0.32 0.32 5498021 0.00 0.00 [whatever] Why does it list 31.07% of time if it only took .32 seconds? Is this a per-call time? (Wouldn't that be self s/call?) This is my first time using gprof , so please be kind :) Edit: by scrolling down, it appears that gprof only thinks my program takes 1.03

Alternative to -pg with Clang?

允我心安 提交于 2019-11-29 06:02:41
问题 I wish to profile CPU (sample if possible), with as small a performance impact as possible (hence similar to GCC's -pg ), binaries compiled with Clang. Is there an alternative that uses instrumentation of the code, or produces output similar to gprof? 回答1: I received a good answer on the Clang mailing list. To summarize, the use of Google Performance Tools was the best fit. 来源: https://stackoverflow.com/questions/3769057/alternative-to-pg-with-clang

gprof : How to generate call graph for functions in shared library that is linked to main program

廉价感情. 提交于 2019-11-28 21:07:58
问题 I am working on Linux environment. I have two 'C' source packages train and test_train. train package when compiled generates libtrain.so test_train links to libtrain.so and generates executable train-test Now I want to generate a call graph using gprof which shows calling sequence of functions in main program as well as those inside libtrain.so I am compiling and linking both packages with -pg option and debugging level is o0. After I do ./train-test , gmon.out is generated. Then I do: $

How does gcc's -pg flag work?

拥有回忆 提交于 2019-11-28 05:01:14
I'm trying to understand how the -pg (or -p ) flag works when compiling C code with gcc . The official gcc documentation only states : -pg Generate extra code to write profile information suitable for the analysis program gprof. You must use this option when compiling the source files you want data about, and you must also use it when linking. This really interests me, as I'm doing a small research on profilers - trying to pick the best tool for the job. Gregory Pakosz Compiling with -pg instruments your code so that gprof reports detailed information, see gprof's manual, 9.1 Implementation of

List of all function calls made in an application

一个人想着一个人 提交于 2019-11-27 18:12:06
How can we list all the functions being called in an application. I tried using GDB but its backtrace list only upto the main function call. I need deeper list i.e list of all the functions being called by the main function and the function being called from these called functions and so on. Is there a way to get this in gdb? Or could you give me suggestions on how to get this? How can we list all the functions being called in an application For any realistically sized application, this list will have thousands of entries, which will probably make it useless. You can find out all functions