wrote:
# since i want to exclude form the counting, the time consume by the
# iteration process itself (the "for" loop), and i need to do this for
# each many different tested tasks, i want to create a macro that -
# register inital cycle count, run a empty loop, check the current cycle
# count and return the difference.
# I want to use a macro and no a function, because calling for a
# function seems effect the amount of cycles the computer uses.
A define simply inserts text into the program without regard
to whether it a statement, an expression, or even C code.
So one thing you could do is
#define intervalStart(n) \
TimeInterval interval; \
{ \
int repeated = (n), repeater; \
Time starttime = clock(); \
for (repeater=1; repeater<=repeated; repeater++) {
#define intervalStop \
} \
Time stoptime = clock(); \
interval = (stoptime-starttime)/repeated; \
}
And then do something like
intervalStart(100)
timed operation
intervalStop
printf("per iteration time = " TimeIntervalFormat "\n",interval);
And of course, many variation on the theme.
--
SM Ryan
http://www.rawbw.com/~wyrmwif/
Haven't you ever heard the customer is always right?