[Home] [Groups] - Message: [Prev in Group] [Next in Group]

nu.kanga.list.mud-dev

22917: Re: [MUD-Dev] Ticks?

[Full Header] [Plain Text]
From: "Eli Stevens" <listsub@wickedgrey.com>
Newsgroups: nu.kanga.list.mud-dev
Date: Thu, 13 Jun 2002 13:41:42 -0500
References: [1] [2] <-newest
Organization: Kanga.Nu
David B. Held <dheld@codelogicconsulting.com> wrote:
> From: "John Buehler" <johnbue@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@kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev