comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com (Tom Moran)
Subject: Re: ADA code execution times
Date: 1998/08/01
Date: 1998-08-01T00:00:00+00:00	[thread overview]
Message-ID: <35c3a695.19034252@SantaClara01.news.InterNex.Net> (raw)
In-Reply-To: 35c354e5.140587456@news.gatech.edu

>What code can I use in my ADA program
Since my ISP seems to have lost my previous post, here it is again:

with Ada.Calendar,
       Ada.Text_IO;
...
use type Ada.Calendar.Time;
Start : Ada.Calendar.Time;
Elapsed : Duration;
...
Start := Ada.Calendar.Clock;
-- something you want to time
Elapsed ::= Ada.Calendar.Clock - Start;
Ada.Text_IO.Put_Line("It took " & Duration'image(Elapsed) 
   & " seconds");

Last time I checked Duration had a delta in the nanoseconds for Gnat,
although it only used the Win95 timer that ticks every 55
milliseconds.  So if "--something you want to time" takes under 55 ms,
the clock will tick 0 or 1 times and you'll get either 0.0 or 0.055 as
the elapsed time.  If it takes, say, 10 seconds, then you'll get
either 10.0 or 10.055 as the printed value.  Since Win95 rears its
head up and does lengthy things like updating the disk at times of its
own choosing, you should take any short duration with a large grain of
salt.  You can of course do the timing multiple times and take the
average.




  reply	other threads:[~1998-08-01  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-01  0:00 ADA code execution times Brian Franklin
1998-08-01  0:00 ` Tom Moran [this message]
1998-08-02  0:00 ` Steve Doiel
1998-08-03  0:00   ` dennison
1998-08-02  0:00 ` Jerry van Dijk
replies disabled

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