Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Benchmarking code with time.h
PostPosted: Sat Sep 05, 2009 2:20 pm 
Offline

Joined: Wed Aug 19, 2009 9:05 am
Posts: 7
Hello,

I have a piece of code that I need to benchmark on a Olimex SAM9-l9260 board running a Linux version 2.6.26.3-olimex (dimitar@lindev.vm) (gcc version 4.2.3 (Sourcery 8) kernel.

I tried to use time.h like this:
Code:
      printf("Computation start\n");
      t1 = clock();

      "DO THE STUFF"
     
      t2 = clock()-t1;
      printf("Computation end\n");
     
      printf ("%.6f\n", (double)(t2+0.0) / CLOCKS_PER_SEC);


But a get unresonable values :(

Anybody have a clue if and how time.h works in this scenario (I don't have to have processor time, wall-clock time is fine for me if that is the only one possible)...

Hope for luck!

Best/Carl


Top
 Profile  
 
 Post subject: Re: Benchmarking code with time.h
PostPosted: Sat Sep 05, 2009 3:02 pm 
Offline

Joined: Tue Jul 07, 2009 7:27 pm
Posts: 7
Forgive me for asking the stupid questions, but:

* Is CLOCKS_PER_SEC a float?

* What kind of "unreasonable values" are you getting?


Top
 Profile  
 
 Post subject: Re: Benchmarking code with time.h
PostPosted: Wed Sep 09, 2009 1:22 pm 
Offline

Joined: Wed Aug 19, 2009 9:05 am
Posts: 7
CLOCKS_PER_SEC seems to be a float, the line

Code:
printf("Clops: %.6f\n"(double)CLOCKS_PER_SEC);


Generates the result:

Clops: 1000000.000000

After a good nights sleep and some measuring with a regular stopwatch the values does not seem unreasonable anymore....

Problem solved...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron