J
junaidnaseer
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 . But this way the
program miscounts ! why ? look below
if ( x==0)
y+y;
else
z+z;
now the program would count two addition operations when only one is
performed .
I was informed by a very nice gentleman from sweden I think that I
could do it like this :
int no_of_add = 0;
if ( x==0 )
y+y;
no_of_add++;
else
z+z;
no_of_add++ ;
this works fine but I have a problem ! My program is 1600 LINES LONG
and its just one FILE in 32 OTHER FILES . I would probably have to
write the entire thing again !
Another option that was brought up by someone was OPERATOR OVERLOADING
.. Well you can forget about that because my program is not written in
classes and OPERATOR OVERLOADING works only for OBJECT Type data , it
will not work on INT or FLOAT . And I can't write the entire program
again because of its length . :C
Can anyone help :-*
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 . But this way the
program miscounts ! why ? look below
if ( x==0)
y+y;
else
z+z;
now the program would count two addition operations when only one is
performed .
I was informed by a very nice gentleman from sweden I think that I
could do it like this :
int no_of_add = 0;
if ( x==0 )
y+y;
no_of_add++;
else
z+z;
no_of_add++ ;
this works fine but I have a problem ! My program is 1600 LINES LONG
and its just one FILE in 32 OTHER FILES . I would probably have to
write the entire thing again !
Another option that was brought up by someone was OPERATOR OVERLOADING
.. Well you can forget about that because my program is not written in
classes and OPERATOR OVERLOADING works only for OBJECT Type data , it
will not work on INT or FLOAT . And I can't write the entire program
again because of its length . :C
Can anyone help :-*