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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!cs.uoregon.edu!ogicse!ucsd!telesoft!rlk From: rlk@telesoft.com (Bob Kitzberger @sation) Newsgroups: comp.lang.ada Subject: Re: HELP! HELP! HELP! need to display DURATION type Summary: ok! ok! ok! Message-ID: <1232@telesoft.com> Date: 12 Apr 91 00:19:40 GMT References: <1991Apr9.034421.7397@cec1.wustl.edu> Distribution: na Organization: TeleSoft, San Diego, CA. List-Id: In some article Lonnie Lee Blackwood writes: > We are doing a timing analysis on our Ada program and need to display > the # seconds elapsed, which is type DURATION. > > DURATION is larger than an integer, so it can't be PUT in the same way. Try this: package Duration_IO is new Text_IO.Fixed_IO( Duration ); Nostril_Hair : Duration := 47.47; . . Duration_IO.Put( Nostril_Hair ); Text_IO.New_Line; . . I didn't run this through a syntax check, so shoot me if your compiler complains ;-) See LRM 14.3.8 for more info. .Bob. p.s. There are many gotchas associated with measuring time with elements of type duration. A few quickies: 1. Duration'Small may be too large for the accuracy you want. 2. Round-off errors in converting from type Duration to other types. 3. The hardware timers (and the device drivers that implement Calendar.Clock and DELAY on top of these hardware timers) may have a resolution that is worse than Duration'Small. For example, Duration'Small is usually 2**-14 (about 61 microseconds) but the underlying timer may provide resolution in the millisecond range. Often you can adapt this portion of the run-time system of your compiler to suit your needs. I don't mean to dissuade you from using values of type Duration... just to point out some potential problem areas. Lest I make a full-blown article out of this p.s., I'll close with a reference about using Ada's timing model: Ted Baker, "Fixing some time-related problems in Ada". In _Proceedings of the Third International Conference on Real-Time Ada Issues (1989). Nelson Weiderman, "Real-Time Programmers Don't Use Calendars." In _Proceedings of the Third International Conference on Real-Time Ada Issues (1989). -- Bob Kitzberger Internet : rlk@telesoft.com TeleSoft uucp : ...!ucsd.ucsd.edu!telesoft!rlk 5959 Cornerstone Court West, San Diego, CA 92121-9891 (619) 457-2700 x163 ------------------------------------------------------------------------------ "Wretches, utter wretches, keep your hands from beans!" -- Empedocles