This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

clock and timing.


I've just coded up this small program

#include <stdio.h>
#include <time.h>

main(){
clock_t start, stop, total;
int count;

start = clock();
printf("%d\n", CLOCKS_PER_SEC);
for(count=0; count < 200000; count++);
stop = clock();
total=stop-start;
printf("total = %lu\n", total);

}                    

The CLOCKS_PER_SEC is 1000000,
When I run the program I get the either
total = 10000
total = 20000
or
total = 0.

Could someone explain what the numbers range so much when the CLOCKS_PER_SEC is so high.
Any help is highly apprieciated.
Thanks


Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]