473,698 Members | 2,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4992
ju**********@gm ail.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_COUN T_OPS
int numberOfAdditio ns(0);
#endif

if ( x==0)
{
y=y+1;
#ifdef WE_WANT_TO_COUN T_OPS
numberOfAdditio ns++;
#endif
}
else
{
y=y+2;
#ifdef WE_WANT_TO_COUN T_OPS
numberOfAdditio ns++;
#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**********@gm ail.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_COUN T_OPS
int numberOfAdditio ns(0);
#endif

if ( x==0)
{
y=y+1;
#ifdef WE_WANT_TO_COUN T_OPS
numberOfAdditio ns++;
#endif
}
else
{
y=y+2;
#ifdef WE_WANT_TO_COUN T_OPS
numberOfAdditio ns++;
#endif
}
Regards,

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


Apr 29 '06 #3
ju**********@gm ail.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
2849
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. After reading the MS KB article 173006 (http://support.microsoft.com/default.aspx?scid=kb;en-us;173006) I increased the locks to 100,000 on the Replica PC and I still get the error. Since the defailt value is only 9500 I would have thought that...
9
10841
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 LDIFDE as a comparison I get the same results. No members means just that, an empty group. Zero means that the DirectorySearcher.SizeLimit has been exceeded....
4
5429
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 server. Data is sent and received over these connections using the asynchronous model. The server is currently in beta testing. Sporadically over the course of the day, I'll observe the thread count on the process (via perfmon) start climbing....
8
4276
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 which is related to the repeater. In the code shown below, if I call Repeater1.Controls.Count in the OnInit (the code fragment was highlighted in yellow) , the viewstate for the repeater will be lost during the postback. You can re-produce this...
68
6807
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
2412
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 that I wanted to find the number of operations ( like additions ,subtractions ,shifts,comparisons ,etc ) performed in a program in runtime . Now one way would be to read the .c or .cpp file and count the number of ' + ' or ' << ' or whatever ....
22
12476
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=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
2
3411
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 results of the analysis are to be stored in a suitable data structure. The main task in this project is to design a suitable ADT (call it WAnalysis) to store the results and enable the following operations to be performed as fast as possible:...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6531
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.