comp.lang.ada
 help / color / mirror / Atom feed
From: rlk@telesoft.com (Bob Kitzberger @sation)
Subject: Re: HELP! HELP! HELP! need to display DURATION type
Date: 12 Apr 91 00:19:40 GMT	[thread overview]
Message-ID: <1232@telesoft.com> (raw)
In-Reply-To: 1991Apr9.034421.7397@cec1.wustl.edu

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

  reply	other threads:[~1991-04-12  0:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-04-09  3:44 HELP! HELP! HELP! need to display DURATION type Lonnie Lee Blackwood
1991-04-12  0:19 ` Bob Kitzberger @sation [this message]
1991-04-12  1:08 ` Michael Feldman
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox