From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 20 01:48:08 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9CFA816A4CE for ; Thu, 20 Jan 2005 01:48:08 +0000 (GMT) Received: from cain.gsoft.com.au (cain.gsoft.com.au [203.31.81.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id A1BDA43D5A for ; Thu, 20 Jan 2005 01:48:05 +0000 (GMT) (envelope-from doconnor@gsoft.com.au) Received: from inchoate.gsoft.com.au (localhost [127.0.0.1]) (authenticated bits=0) by cain.gsoft.com.au (8.12.11/8.12.10) with ESMTP id j0K1m1CR006223; Thu, 20 Jan 2005 12:18:01 +1030 (CST) (envelope-from doconnor@gsoft.com.au) From: "Daniel O'Connor" To: freebsd-hackers@freebsd.org Date: Thu, 20 Jan 2005 12:17:59 +1030 User-Agent: KMail/1.7.1 References: <20050120004406.GF921@einstein.lab> In-Reply-To: <20050120004406.GF921@einstein.lab> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3490558.pWnpvR1U58"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200501201218.00400.doconnor@gsoft.com.au> X-Spam-Score: -4.6 () IN_REP_TO,PGP_SIGNATURE_2,REFERENCES,SPAM_PHRASE_00_01,USER_AGENT,USER_AGENT_KMAIL X-Scanned-By: MIMEDefang 2.16 (www . roaringpenguin . com / mimedefang) cc: Marco Trentini Subject: Re: clock time in milliseconds into a c program X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jan 2005 01:48:08 -0000 --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--