From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,51aec3e725649fde X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-28 19:33:37 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!wn1feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3BB5330E.806F9097@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Fairly simple question about using time in Ada References: <3bb5234f$0$9274$afc38c87@news.optusnet.com.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 29 Sep 2001 02:33:37 GMT NNTP-Posting-Host: 12.86.34.165 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1001730817 12.86.34.165 (Sat, 29 Sep 2001 02:33:37 GMT) NNTP-Posting-Date: Sat, 29 Sep 2001 02:33:37 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:13502 Date: 2001-09-29T02:33:37+00:00 List-Id: Chris, I hope you have access to a copy of the Language Reference Manual. It is very helpful. You want to use the Ada.Calendar package. This package defines a number of useful types and subprograms. The "time" type is used to hold an absolute time value. Its resolution is at least to the 0.1 millisecond level. The Ada.Calendar package also defines a function taking no parameters called "clock". Clock returns a time value (the current time). There is also a definition of the subtraction function "-" for two time values. This function returns a duration value. Duration is defined as a fixed-point type. Values to the left of the radix (decimal point) represent whole seconds. Values to the right of the radix represent fractional seconds. A duration value of 10.001 would then represent 10 seconds plus one millisecond. I hope this information helps. Just a little note, the Ada.Calendar.Time type is useful for relatively gross timings. If you want finer timing capability you need to use a compiler implementing the Real-Time annex for Ada. This will allow you to time events to a granularity no rougher than 0.1 microseconds. I assume you will not be needing such a fine level of timing. Jim Rogers Colorado Springs, Colorado USA Chris Vinall wrote: > > I'm writing a program in which I need to be able to timestamp events and > then later check how much real time has elapsed since that event occurred. > It is essential that this timing operate to tenths of a second and > hundredths of a second would be a lot better. > > How do I go about doing this in Ada? My textbook mentioned something about > Duration but was less than helpful. > > Thanks for any help > > Chris