Execution time

Topics for the Eclipse Environment
Post Reply
cbein
Posts: 8
Joined: Mon Jul 08, 2013 8:01 am

Execution time

Post by cbein »

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:

Code: Select all

#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:

Code: Select all

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
User avatar
dciliske
Posts: 623
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: Execution time

Post by dciliske »

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.

-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
cbein
Posts: 8
Joined: Mon Jul 08, 2013 8:01 am

Re: Execution time

Post by cbein »

Thanks. The HiResTimer worked great. That is a much better approach.

Jared
Post Reply