473,406 Members | 2,549 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,406 software developers and data experts.

Count the actual number of operations performed during run time

Is it possible to actually count the number of addition or
multiplication operations performed in a program during runtime . I
know of a program that does this simply by looking through the code for
* and + operators but the problem is that this program is fooled when
we use if...else structures coz there might be a + in the if part but
the if part of the statement might not be getting actually called in a
particular execution of the program . here is a sample

if ( x==0)
y=y+1;
else
y=y+2;

now upon execution only one plus is executed but the code parsing
technique would give an answer of two which is wrong . I know there is
a way to actually count the number of operations performed during
runtime but i dont quite know how . I have to get this info to some one
else urgent so any one who knows about this plz help !

Apr 29 '06 #1
3 4963
ju**********@gmail.com wrote:
Is it possible to actually count the number of addition or
multiplication operations performed in a program during runtime . I
know of a program that does this simply by looking through the code for
* and + operators but the problem is that this program is fooled when
we use if...else structures coz there might be a + in the if part but
the if part of the statement might not be getting actually called in a
particular execution of the program . here is a sample

if ( x==0)
y=y+1;
else
y=y+2;

now upon execution only one plus is executed but the code parsing
technique would give an answer of two which is wrong . I know there is
a way to actually count the number of operations performed during
runtime but i dont quite know how . I have to get this info to some one
else urgent so any one who knows about this plz help !


How about counting all the operations by inserting code of your own?
For example, like the following;
#ifdef WE_WANT_TO_COUNT_OPS
int numberOfAdditions(0);
#endif

if ( x==0)
{
y=y+1;
#ifdef WE_WANT_TO_COUNT_OPS
numberOfAdditions++;
#endif
}
else
{
y=y+2;
#ifdef WE_WANT_TO_COUNT_OPS
numberOfAdditions++;
#endif
}
Regards,

Peter Jansson
http://www.p-jansson.com/
http://www.jansson.net/
Apr 29 '06 #2
u can delete this post if u want to , in order to cover my stupidity
Peter Jansson wrote:
ju**********@gmail.com wrote:
Is it possible to actually count the number of addition or
multiplication operations performed in a program during runtime . I
know of a program that does this simply by looking through the code for
* and + operators but the problem is that this program is fooled when
we use if...else structures coz there might be a + in the if part but
the if part of the statement might not be getting actually called in a
particular execution of the program . here is a sample

if ( x==0)
y=y+1;
else
y=y+2;

now upon execution only one plus is executed but the code parsing
technique would give an answer of two which is wrong . I know there is
a way to actually count the number of operations performed during
runtime but i dont quite know how . I have to get this info to some one
else urgent so any one who knows about this plz help !


How about counting all the operations by inserting code of your own?
For example, like the following;
#ifdef WE_WANT_TO_COUNT_OPS
int numberOfAdditions(0);
#endif

if ( x==0)
{
y=y+1;
#ifdef WE_WANT_TO_COUNT_OPS
numberOfAdditions++;
#endif
}
else
{
y=y+2;
#ifdef WE_WANT_TO_COUNT_OPS
numberOfAdditions++;
#endif
}
Regards,

Peter Jansson
http://www.p-jansson.com/
http://www.jansson.net/


Apr 29 '06 #3
ju**********@gmail.com wrote:
u can delete this post if u want to ,


Whoever 'u' is, he probably can't.

Apr 30 '06 #4

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

Similar topics

8
by: Bri | last post by:
Greetings, After making various edits and deletes on aproximately 40,000 records in one table (on the Design Master) syncronization fails with Error 3052 - File Sharing Lock Count Exceeded....
9
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
68
by: Martin Joergensen | last post by:
Hi, I have some files which has the following content: 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0
9
by: junaidnaseer | last post by:
ok I know I posted this question previously and then I got a reply and I realized that I had asked a really dumb question but now I realize that my question wasn't that dumb at all ! I had asked...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
2
by: alwaali | last post by:
Hi I need help please This is my project and i need a help to solve it with you A page of text is to be read and analyzed to determine number of occurrences and locations of different words. The...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.