Hi, I need to clock the function execution time into a C program. I know /usr/include/time.h library but I need to clock the time in milliseconds.
Any suggestions, links?
---snip--- #include <sys/time.h>
struct timeval tv1,tv2; struct timezone tz1,tz2;
gettimeofday(&tv1,&tz1);
for (i=0;i<5000000;i++) { tmp=tree_insert(myroot,i,i+10); // cycles if (tmp) myroot=tmp; // cycles } gettimeofday(&tv2,&tz2);
fprintf(stderr,"Insertion of 5 billions lasted %d microseconds\n", ((tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec))); ---snip---
So you can measure the cycles multiple times then compute the average time.
For this snippet (which deals with a B+tree) i got results of the form 0.3445866564 microseconds, which means 344.5867 miliseconds.. etc..
I don't think there is a streight way to speed-up the default unix time resolution, which is, as far as i know, in microseconds.
Regards, -- Alin-Adrian Anton GPG keyID 0x1E2FFF2E (2963 0C11 1AF1 96F6 0030 6EE9 D323 639D 1E2F FF2E) gpg --keyserver pgp.mit.edu --recv-keys 1E2FFF2E
Never ask a man what OS he uses. If it's FreeBSD, he'll tell you. If it's not, why embarrass him? ..I'm sorry.. _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"