Date: Thu, 20 Jan 2005 12:17:59 +1030 From: "Daniel O'Connor" <doconnor@gsoft.com.au> To: freebsd-hackers@freebsd.org Cc: Marco Trentini <mark@remotelab.org> Subject: Re: clock time in milliseconds into a c program Message-ID: <200501201218.00400.doconnor@gsoft.com.au> In-Reply-To: <20050120004406.GF921@einstein.lab> References: <20050120004406.GF921@einstein.lab>
next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart3490558.pWnpvR1U58 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thu, 20 Jan 2005 11:14, Marco Trentini wrote: > 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. How about.. struct timeval then, now; gettimeofday(&then, NULL); somefunction(); gettimeofday(&now, NULL); timespecsub(&now, &then); printf("function took %ld milliseconds to run\n", now.tv_sec * 1000 + =20 now.tv_usec / 1000); =2D-=20 Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C --nextPart3490558.pWnpvR1U58 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQBB7w3Q5ZPcIHs/zowRApFpAJ9bhblG0loagoELVknbUleHmUNiXwCeM2jM RBlyF/gUYu5GcOWRUGJ9DQ8= =q6EA -----END PGP SIGNATURE----- --nextPart3490558.pWnpvR1U58--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200501201218.00400.doconnor>