From: Simon Wright <simon@pushface.org>
Subject: Re: Timing Block of GNAT code in milliseconds
Date: 21 Apr 2005 20:44:17 +0100
Date: 2005-04-21T20:44:17+01:00 [thread overview]
Message-ID: <x7vfyxj7w4u.fsf@smaug.pushface.org> (raw)
In-Reply-To: 1114109602.373794.96920@l41g2000cwc.googlegroups.com
"markp" <markwork66@yahoo.com> writes:
> Thanks for your response:
>
> I tried this and got some errors. Hereis what my code looks like
>
> My_Time : Ada.Calendar.Time;
> Result : Ada.Calendar.Time;
>
> My_Time := Ada.Calendar.Clock;
> Result := (Ada.Calendar.Clock - My_Time)/1000;
>
> The error I get is :
>
> Expected private type Ada.Calendar.Time
> Expected type Standard Duration
>
> on the piece of code (Ada.Calendar.Clock - My_Time).
You need to say
use type Ada.Calendar.Time;
in a declarative region (I usually put this just before the 'begin').
That gives you access to the operation "-" taking two parameters of
type Ada.Calendar.Time and returning a Duration; your Result should be
of type Duration (a Time corresponds to the wall-clock time, whereas
Duration is an interval).
The error message you got is reasonable; if you subtract "4 Jan 2004"
from "4 Jan 2005", you get "1 year" not "1 Jan 1971"!
> Lastly,
>
> How would I print out Result?
Did you say what compiler/platform you're using?
On any platform you can say (eg)
Ada.Text_IO.Put_Line ("Result is " & Duration'Image (Result));
GNAT has the non-portable extension 'Img so you can say
Ada.Text_IO.Put_Line ("Result is " & Result'Img);
--
Simon Wright 100% Ada, no bugs.
next prev parent reply other threads:[~2005-04-21 19:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-21 13:28 Timing Block of GNAT code in milliseconds markp
2005-04-21 18:00 ` tmoran
2005-04-21 18:53 ` markp
2005-04-21 19:40 ` Marc A. Criley
2005-04-21 19:44 ` Simon Wright [this message]
2005-04-22 1:00 ` Steve
2005-04-23 5:39 ` Simon Wright
2005-04-23 17:49 ` Steve
2005-04-24 18:57 ` Simon Wright
2005-04-24 20:05 ` Dmitry A. Kazakov
2005-04-25 22:56 ` Randy Brukardt
2005-04-28 20:26 ` Simon Wright
2005-04-29 8:11 ` Dmitry A. Kazakov
2005-04-29 18:25 ` tmoran
2005-04-29 19:19 ` Dmitry A. Kazakov
2005-04-29 20:24 ` tmoran
2005-04-30 9:47 ` Dmitry A. Kazakov
2005-04-29 20:52 ` Randy Brukardt
2005-04-30 10:02 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox