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-Thread: 103376,d1f23f0bd3971bec X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!newsfeed.stueberl.de!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Timing Block of GNAT code in milliseconds Date: 21 Apr 2005 20:44:17 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <1114090119.383842.20950@l41g2000cwc.googlegroups.com> <1114109602.373794.96920@l41g2000cwc.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1114112776 12775 62.49.19.209 (21 Apr 2005 19:46:16 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Thu, 21 Apr 2005 19:46:16 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: g2news1.google.com comp.lang.ada:10633 Date: 2005-04-21T20:44:17+01:00 List-Id: "markp" 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.