I am currently working on a project where the execution time is critical. I am trying to use time.h to record the time at different parts of execution, but I am receiving an undefined reference error to 'times'. The code is given below:
#include <time.h>
clock_t startt, stopt;
#define START starttime = clock();
#define STOP stoptime = clock();
#define PRINTTIME printf( "%6.3f seconds recorded.", ((double)stoptime-starttime)/CLOCKS_PER_SEC);
START;
here I put the code to execute...
STOP;
PRINTTIME;
I am not sure the best way to do this with the netburner. This is the way I normally checked execution time before, but this doesn't work here. I am using a NBEclipse release 2.6.2 and MOD54415. Below is the error I receive:
c:/nburn/gcc-m68k/bin/../lib/gcc/m68k-elf/4.2.1/../../../../m68k-elf/lib/m5206e\libc.a(lib_a-times.o): In function `_times_r':
times.c:(.text+0xe): undefined reference to `times'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Hmm... I'm not sure what's going on with the undefined reference, but to begin with, I think you're using the wrong methodology. You really want to be using the HiResTimer class or one of the hardware timers directly if extreme precision is required. Take a look at the HiResTimer example in the 'utils' examples.