can any one help me about calculating the exact execution time of processor

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
eswar.aspire eswar.aspire is offline Offline Nov 9th, 2009, 5:49 pm |
1
hi,

Can any one help me about clock problem..i need to calculate the exact execution time of algorithm using the processor clock speed not the wall clock time..i am getting zero by using the clock_t function in time.h.also how can i calculate the exact processor speed execution of program..reply me as soon as possible.
Quick reply to this message  
C Syntax
  1. for example
  2. #include<stdio.h>
  3. #include<time.h>
  4. int main()
  5. {
  6. clock_t start,end;
  7. start=clock();
  8. bubblesort(array,arraysize);
  9. end=clock();
  10. printf("the clock speed: %f",start-end);
  11. getch();
  12.  
  13. }
1
AuSsIeStOnE AuSsIeStOnE is offline Offline | 30 Days Ago
your code: " printf("the clock speed: %f",start-end); "

Hey dude, change to: end - start to obtain time in miliseconds
or (end - start) / 1000.0 for time in seconds.miliseconds

(and don't forget to declare double start, end; )
Last edited by AuSsIeStOnE; 30 Days Ago at 8:36 pm.
 
 

Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC