dsr@stl.stc.co.uk (David Riches) (07/14/89)
Has anyone got a timestamp routine, written in C, which has a resolution of milliseconds (possibly lower)? Dave Riches PSS: dsr@stl.stc.co.uk ARPA: dsr%stl.stc.co.uk@earn-relay.ac.uk Smail: Software Design Centre, (Dept. 103, T2 West), STC Technology Ltd., London Road, Harlow, Essex. CM17 9NA. England Phone: +44 (0)279-29531 x2496
scs@adam.pika.mit.edu (Steve Summit) (07/15/89)
In article <1595@stl.stc.co.uk> dsr@stl.stc.co.uk (David Riches) writes: >Has anyone got a timestamp routine, written in C, which has a >resolution of milliseconds (possibly lower)? The implementation of such a routine would be highly system- dependent. A somewhat standard but little-known routine already exists which provides what you want: ftime(). It returns a structure which "contains the time since the epoch in seconds, [and] up to 1000 milliseconds of more-precise interval." If your vendor happens to provide an implementation of this routine, you're in luck; if not, there's not much portable you can do. (X3J11 doesn't appear to help, and neither does POSIX, which I just discovered doesn't endorse ftime, which is a miserable omission, but not a topic for this newsgroup.) Steve Summit scs@adam.pika.mit.edu P.S. Microsoft supplies ftime() for MS-DOS; the version of TurboC I've used doesn't (although later versions may have added it).
craigb@hp-sdd.hp.com (Craig Bosworth) (07/18/89)
Turbo C 2.0 does have ftime(). It returns seconds and milliseconds since midnight GMT, 1-1-70. The actual resolution is 5 or 6 hundreths. It is in the Reference Guide, p. 146. BOS -- Craig Bosworth (619) 592-8609 16399 West Bernardo Drive Hewlett-Packard, San Diego Division San Diego, CA 92127-1899 UUCP : {hplabs|nosc|hpfcla|ucsd}!hp-sdd!craigb Internet : craigb%hp-sdd@hp-sde.sde.hp.com (or @nosc.mil, @ucsd.edu)
guy@auspex.auspex.com (Guy Harris) (07/18/89)
>The implementation of such a routine would be highly system- >dependent. A somewhat standard but little-known routine already >exists which provides what you want: ftime(). 1) "somewhat standard" is the key word here. In the UNIX world, it's in V7, and in 4.xBSD, but not in System V. >It returns a structure which "contains the time since the epoch in seconds, >[and] up to 1000 milliseconds of more-precise interval." 2) "more precise" doesn't necessarily mean "precise down to the millisecond"; it will probably reflect the resolution of the OSes clock, which is may well be closer to 10 milliseconds than one millisecond. >If your vendor happens to provide an implementation of this >routine, you're in luck; if not, there's not much portable you >can do. Unless your vendor happens to provide an implementation of "gettimeofday()", which first appeared in 4.2BSD, and upon which "ftime()" is implemented in 4.xBSD and many systems that picked up "gettimeofday()" from it. The previous comment about resolution applies to it as well....