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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,101c38a932801b81,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!e23g2000prf.googlegroups.com!not-for-mail From: kongra Newsgroups: comp.lang.ada Subject: Ada.Real_Time behavior with GNAT Date: Sat, 29 Mar 2008 06:51:58 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 83.26.235.159 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1206798718 27021 127.0.0.1 (29 Mar 2008 13:51:58 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 29 Mar 2008 13:51:58 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e23g2000prf.googlegroups.com; posting-host=83.26.235.159; posting-account=8ledOwoAAACzwtoronhUWHsxPqF356aB User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20628 Date: 2008-03-29T06:51:58-07:00 List-Id: Hi everybody. I have a question related to the Ada.Real_Time package. When I compile the following code using GNAT GPL 2007 on Windows XP SP2 I observe some strange looking behavior. with Ada.Real_Time; with Ada.Text_IO; procedure Timing is Start_T : Ada.Real_Time.Time; End_T : Ada.Real_Time.Time; Total_T : Duration; Sleep_T : constant Duration := Duration (0.0001); use Ada.Real_Time; Val : Integer := 0; begin -- delay Sleep_T; Start_T := Ada.Real_Time.Clock; for K in 1 .. 10 loop for I in 1 .. 10_000_000 loop Val := Val + I; end loop; end loop; End_T := Ada.Real_Time.Clock; Total_T := Ada.Real_Time.To_Duration (End_T - Start_T); Ada.Text_IO.Put_Line (Integer'Image (Val)); Ada.Text_IO.Put_Line (Duration'Image (Total_T)); end Timing; The compilation command is pretty straightforward: gnatmake Timing.adb -o timing.exe. Running timing.exe I get 1432236160 0.000000000 To my surprise the total time is 0 here, though performing all the computations takes some observable time. However removing comment in the line containing statement delay Sleep_T; causes 1432236160 0.431441426 Apparently the total duration seems correct now. I get a similar change by putting with Ada.Calendar; to the compilation unit (without completely using it). Moreover the delay statement has got the same impact on the program execution even when it's placed in some procedure other than Timing and the procedure is not used at all. I tried the same code in a bigger project using switches like those in the Ada Wikibooks examples, getting the same. Can it be explained or is there something I don't know about timing in Ada ? I'm a beginner in Ada (after 7+ years Java coding) and I think it's a great programming language, worth to be promoted among students. But this one really surprised me even if I was able to avoid using Ada.Calendar (for example prohibited by Ravenscar profile) using a hack with delay. Best regards, Konrad Grzanek.