First,
tic() and
toc() functions. These work like Matlab:
tic() starts the timer, and
toc() stops it and gives formatted output. There’s also a
tocq() function which just returns the number of elapsed seconds.
#include <time.h>
static clock_t tic_timestart;
void tic(void) {
tic_timestart = clock();
}
float toc(void) {
clock_t tic_timestop;
tic_timestop = clock();
printf("time: %8.2f.\n", (float)(tic_timestop - tic_timestart) / CLOCKS_PER_SEC);
return (float)(tic_timestop - tic_timestart) / CLOCKS_PER_SEC;
}
float tocq(void) {
clock_t tic_timestop;
tic_timestop = clock();
return (float)(tic_timestop - tic_timestart) / CLOCKS_PER_SEC;
}
A bit of code for counting flops: first, a
statistics structure, then some defines.
typedef struct statistics_t *statistics;
typedef struct statistics_t {
long div;
long add;
long mul;
long asn;
long sto;
long tfr;
long ntf;
long com;
} Statistics;