Counting function calls



 DEVELOP > c-Plus-Plus > Counting function calls

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 01 Jan 2008 06:11:18 AM
Object: Counting function calls
Hello,
does anybody know a "tool" or an easy method to measure the count of
function/member function calls? I just would like some kind of
statistic or raw numbers, how often a specific function is called.
Best regards,
T. Schilling
.

User: "red floyd"

Title: Re: Counting function calls 01 Jan 2008 12:57:15 PM
wrote:

Hello,

does anybody know a "tool" or an easy method to measure the count of
function/member function calls? I just would like some kind of
statistic or raw numbers, how often a specific function is called.

It's called a "Profiler". It's toolset dependent.
.

User: "=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?="

Title: Re: Counting function calls 01 Jan 2008 07:23:18 AM
On 2008-01-01 13:11,
wrote:

Hello,

does anybody know a "tool" or an easy method to measure the count of
function/member function calls? I just would like some kind of
statistic or raw numbers, how often a specific function is called.

Seems to me like something a profiler should should be able to do.
--
Erik Wikström
.

User: "=?utf-8?Q?David_C=C3=B4me?="

Title: Re: Counting function calls 01 Jan 2008 06:16:28 AM
On Tue, 01 Jan 2008 13:11:18 +0100, <thorsten.schilling@gmail.com> wrote:

Hello,

does anybody know a "tool" or an easy method to measure the count of
function/member function calls? I just would like some kind of
statistic or raw numbers, how often a specific function is called.

Best regards,
T. Schilling

static variable into the function with incrementation like this:
#include <iostream>
void foo(void)
{
static int num;
std::cout<<num<<std::endl;
num++;
}
int main(void)
{
foo();
foo();
}
.
User: ""

Title: Re: Counting function calls 01 Jan 2008 06:35:27 AM
David C=F4me schrieb:

On Tue, 01 Jan 2008 13:11:18 +0100, <thorsten.schilling@gmail.com> wrote:

Hello,

does anybody know a "tool" or an easy method to measure the count of
function/member function calls? I just would like some kind of
statistic or raw numbers, how often a specific function is called.

Best regards,
T. Schilling


static variable into the function with incrementation like this:
#include <iostream>

void foo(void)
{
static int num;
std::cout<<num<<std::endl;
num++;
}

int main(void)
{
foo();
foo();
}

Hello,
yes, that is the obvious solution. But in a program with roughly
approximated 2000 functions it would be extremly intensive to change
every function to that style, or I would say impossible depicted in
hours of work. I am looking more for some debugger function, e.g. in
gdb, which tells me the count of the calls the functions recieved
after a successfull program run.
Best regards,
T. Schilling
.
User: "Marc"

Title: Re: Counting function calls 01 Jan 2008 08:21:27 AM

yes, that is the obvious solution. But in a program with roughly
approximated 2000 functions it would be extremly intensive to change
every function to that style, or I would say impossible depicted in
hours of work. I am looking more for some debugger function, e.g. in
gdb, which tells me the count of the calls the functions recieved
after a successfull program run.

What you need is a profile of your program. If you are using g++, compile
and link it with flag -pg enabled (not sure if this also implies -g). Then,
run your program as usual. When you finish, you will notice a new file
named gmon.out. This contains all the information the profiler was able to
collect. You can see this information with gprof NAME_OF_YOUR_PROGRAM, or
using a graphical viewer, like kprof.
You can see how many times every function was called, how many time it took,
and some other useful stuff.
Marc
.




  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER