Re: generic profiler for C code?

kamal <>
Sun, 8 Feb 2009 01:48:46 -0800 (PST)

          From comp.compilers

Related articles
generic profiler for C code? (ssylee) (2009-01-27)
Re: generic profiler for C code? (ssylee) (2009-01-27)
Re: generic profiler for C code? (kamal) (2009-02-08)
| List of all articles for this month |

From: kamal <>
Newsgroups: comp.compilers
Date: Sun, 8 Feb 2009 01:48:46 -0800 (PST)
Organization: Compilers Central
References: 09-01-054 09-01-057
Keywords: C, performance, tools
Posted-Date: 10 Feb 2009 09:36:26 EST

On Jan 28, 9:39 am, ssylee <> wrote:
> On Jan 27, 12:43 pm, ssylee <> wrote:
> > I'm running the C/C++ file to be generated as a mex file, used by m-file
> > in Matlab. However, I'm not sure if there are any generic profiler
> > libraries where I can just insert profiler function calls between the
> > function execution that I want to test out. It would be great for some
> > feedback.

if it is a binary generated by a C/C++ compiler, you can use the
standard gprof utility that uses a profiler library.

It can tell you how many times a function was called in a call graph,
and also provide a histogram as to where the program spent most of its
time executing. The locatiion is in terms of which instructions or C/C+
+ language statements (approximately) the program spent executing. The
histogram is generated based on what the PC value was, when a clock
interrupt occurred in the kernel (once every 10 ms usually).

> > [What are you trying to profile? Time per call? Number of calls?
> > Ranges of arguments? Something else? -John]
> To add to my question, I'm trying to profile function call execution
> times in my mex-generating C++ source code for Matlab (i.e. time per
> call).

If the gprof output isn't good enough, you will have to extend the
framework (i.e. add calls in generated code to functions in profiler

Hope that helps.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.