[MUD-Dev] Ticks?
Eli Stevens
listsub at wickedgrey.com
Thu Jun 13 13:41:42 CEST 2002
David B. Held <dheld at codelogicconsulting.com> wrote:
> From: "John Buehler" <johnbue at msn.com>
>> Try a system service that works at a very low level, such as
>> elapsed clock cycles.
> I assume here you mean something like clock() in ANSI C? That
> probably does give you the highest portable timer resolution, but
> it gives you processor time, instead of wall clock time (at least
> on my server's implementation, which I assume must be standard-
> conforming).
#include <sys/timeb.h> // and <sys/types.h> under win32 (?)
int ftime(struct timeb *tp); // void _ftime under win32, but I suspect
// that ftime is a macro that does the
// same thing
One can use the ftime function to fill a timeb struct with the
seconds and milliseconds since the epoch, along with the timezone
and daylight savings time status. This is wall clock time, not
process time. IIRC, clock() gives a higher resolution
(microseconds, at least on my Linux box), but I am having a hard
time picturing a situation where that kind of accuracy is really
needed.
I went through this a few months ago, looking for a millisecond
accurate wall clock time function. I was somewhat surprised at how
long it took me to find it (maybe I was using the wrong search terms
:). Also note that it is timeb.h, not time.h (which may have been
another reason it wasn't easy to find - I may have only been looking
in time.h docs).
Anyway, HTH.
Eli
--
Give a man some mud, and he plays for a day.
Teach a man to mud, and he plays for a lifetime.
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list