473,378 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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
Jan 1 '08 #1
5 10327
On Tue, 01 Jan 2008 13:11:18 +0100, <th****************@gmail.comwrote:
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();
}
Jan 1 '08 #2


David Côme schrieb:
On Tue, 01 Jan 2008 13:11:18 +0100, <th****************@gmail.comwrote:
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
Jan 1 '08 #3
On 2008-01-01 13:11, th****************@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.
Seems to me like something a profiler should should be able to do.

--
Erik Wikström
Jan 1 '08 #4
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
Jan 1 '08 #5
th****************@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.
It's called a "Profiler". It's toolset dependent.
Jan 1 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Elbert Lev | last post by:
Please correct me if I'm wrong. Python (as I understand) uses reference counting to determine when to delete the object. As soon as the object goes out of the scope it is deleted. Python does...
3
by: Megan | last post by:
hi everybody- i'm having a counting problem i hope you guys and gals could give me some help with. i have a query that retrieves a bevy of information from several different tables. first let...
7
by: sathyashrayan | last post by:
Group, Following function will check weather a bit is set in the given variouble x. int bit_count(long x) { int n = 0; /* ** The loop will execute once for each bit of x set,
1
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
10
by: cj | last post by:
I'm writing a TCP/IP server app that will have many simultaneous connections. The main thread listens for new connections and starts a thread to handle each requested connection. These are short...
14
by: ranjmis | last post by:
Hi all, Below is the code wherein I am initializing double dimentional array inside main with string literals. Now I want to display the strings using a function call to which I just want to...
14
by: Dan | last post by:
Is this discouraged?: for line in open(filename): <do something with line> That is, should I do this instead?: fileptr = open(filename) for line in fileptr: <do something with line>
27
by: Simon Biber | last post by:
I was reading http://en.wikipedia.org/wiki/Poker_probability which has a good description of how to count the frequency of different types of poker hands using a mathematical approach. A sample...
1
by: =?ISO-8859-1?Q?Ricardo_Ar=E1oz?= | last post by:
Hi, I know I'm being dumb but, why does it not work? .... def __init__(self): .... self.calls = 0 .... def __getattr__(self, name): .... self.calls += 1 .... ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.