Timers and timing, was: MySQL Performance 6.0rc1
Benjamin Lutz
benlutz at datacomm.ch
Fri Oct 28 12:32:44 PDT 2005
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 186 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20051028/71a925f2/signature.bin
More information about the freebsd-current
mailing list