#define timeit(et, stmts) \
{struct timeb _ts; \
register int _i; \
(void) ftime(&_ts); \
et = _ts.time*1000 + _ts.millitm; \
for (_i = 0; _i < loop_maximum; _i++) { stmts ; } \
(void) ftime(&_ts); \
et = _ts.time*1000 + _ts.millitm - et; }1
can be used to measure the execution time of practically any C code segment. For example:
time_t s; timeit(s, (void) fwrite(c, sizeof(char), write_size, f); (void) fflush(f));
measures the cost of writing all the way out to disk some number (given by
write_size) of characters.