From owner-freebsd-current@FreeBSD.ORG Fri Oct 28 19:32:44 2005 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6F60616A41F for ; Fri, 28 Oct 2005 19:32:44 +0000 (GMT) (envelope-from benlutz@datacomm.ch) Received: from maxlor.mine.nu (c-213-160-32-54.customer.ggaweb.ch [213.160.32.54]) by mx1.FreeBSD.org (Postfix) with ESMTP id E96EA43D46 for ; Fri, 28 Oct 2005 19:32:43 +0000 (GMT) (envelope-from benlutz@datacomm.ch) Received: from localhost (unknown [127.0.0.1]) by maxlor.mine.nu (Postfix) with ESMTP id 97F662E03B; Fri, 28 Oct 2005 21:32:19 +0200 (CEST) Received: from maxlor.mine.nu ([127.0.0.1]) by localhost (atlantis.intranet [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 79135-05; Fri, 28 Oct 2005 21:32:18 +0200 (CEST) Received: from [10.0.0.17] (mini.intranet [10.0.0.17]) by maxlor.mine.nu (Postfix) with ESMTP id 397602E038; Fri, 28 Oct 2005 21:32:18 +0200 (CEST) Message-ID: <43627CCB.2060508@datacomm.ch> Date: Fri, 28 Oct 2005 21:32:27 +0200 From: Benjamin Lutz User-Agent: Mozilla Thunderbird 1.0.7 (Macintosh/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Chuck Swiger References: <26845.1130452524@critter.freebsd.dk> <436167D5.2060104@mac.com> In-Reply-To: <436167D5.2060104@mac.com> X-Enigmail-Version: 0.92.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigDC457EE6FB52F5851F11A1DF" X-Virus-Scanned: amavisd-new at atlantis.intranet Cc: current@freebsd.org Subject: Re: Timers and timing, was: MySQL Performance 6.0rc1 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2005 19:32:44 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigDC457EE6FB52F5851F11A1DF Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Chuck Swiger wrote: > For one case, I have some code which needs to update statistics like > "packets sent per second" (or "per minute" or "per hour") on a periodic > basis. I use a reasonable timeout-- ~50ms-- for a call to select() (or > pcap_dispatch(), etc) so I check time() perhaps 20 times a second, and > then update my per-second stats when I notice that time(&now) returns a > different value. > > Is there a better way of running code once a second, as close to the > time the clock ticks? Once you've seen the clock tick, you can then probably use a longer timeout in the next select, something in the 700ms range? Cheers Benjamin --------------enigDC457EE6FB52F5851F11A1DF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Darwin) iD8DBQFDYnzPgShs4qbRdeQRAq6bAJ9JSoYAhCKU+SEVGW+xcLOkw5aNagCfS6tN y7+z4wb/0m/Q30PSa5tmGoE= =tlux -----END PGP SIGNATURE----- --------------enigDC457EE6FB52F5851F11A1DF--