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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a889ad4a86a5caa4 X-Google-Attributes: gid103376,public From: tmoran@bix.com (Tom Moran) Subject: Re: ADA code execution times Date: 1998/08/01 Message-ID: <35c3a695.19034252@SantaClara01.news.InterNex.Net>#1/1 X-Deja-AN: 377085799 References: <35c354e5.140587456@news.gatech.edu> Organization: InterNex Information Services 1-800-595-3333 Newsgroups: comp.lang.ada Date: 1998-08-01T00:00:00+00:00 List-Id: >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.