Mail Archives: djgpp/1998/02/11/00:33:54
At 08:52 2/10/1998 +0100, Tom Chojnacki wrote:
>I want to measure time intervals in which some function executes itself.
>I used clock() function which returns time which elapsed since first
>call to clock(). But how can I reset the clock() to measure another time
>interval and not time since the first call again.
As far as I know, you can't. Your best bet is to save the value returned at
the start of the interesting time and subtract the value returned at the
end. i.e.:
clock_t start_clock;
start_clock = clock();
/* Code */
printf("Took %lu ticks\n", (unsigned long)clock() - start_clock);
>Are there any alternative time measuring functions which I could use ?.
Not that will do what you want. There is `gettimeofday', but it's more
complicated to use. Also, under other operating systems, it will give
different results. (`clock' measures CPU time used while `gettimeofday'
measures real time, but on single-tasking DOS they're the same.)
Nate Eldredge
eldredge AT ap DOT net
- Raw text -