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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c8acfc87fbb1813d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!news4.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!87.79.20.105.MISMATCH!news.netcologne.de!ramfeed1.netcologne.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Timing code blocks Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <2d5bead9-72f9-4c84-9ac1-a058c2591ef1@c37g2000prb.googlegroups.com> <13j6juslcud2k.1n4jnpj74p3k$.dlg@40tude.net> <12e4d91f-9c23-49fb-a413-97c0375a1668@s36g2000prf.googlegroups.com> Date: Fri, 5 Mar 2010 09:49:42 +0100 Message-ID: <7ihvqmo8zt91.eraboux3xzzj$.dlg@40tude.net> NNTP-Posting-Date: 05 Mar 2010 09:49:40 CET NNTP-Posting-Host: bd21ce86.newsspool2.arcor-online.net X-Trace: DXC=4\e>146WC98T2Rfi6[5fR77^m?a70< X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:9418 Date: 2010-03-05T09:49:40+01:00 List-Id: On Fri, 5 Mar 2010 00:16:52 -0800 (PST), deadlyhead wrote: > On Mar 4, 11:55�pm, "Dmitry A. Kazakov" > wrote: >> >> This is an ancient bug, which managed to survive a number of GNAT compiler >> versions. >> >> As a workaround, add delay 0.0 at the beginning of your program: >> >>> ---------------------------------------------------------------------- >> >>> -- �A test of the cost of conditionals >> >>> with Ada.Text_IO; �use Ada.Text_IO; >>> with Ada.Real_Time; use Ada.Real_Time; >>> procedure Conditional_Test is >> > > Exactly what was needed. Thank you! > > Do you happen to know if this bug has been fixed in the current > development branch? (At home I compile GNAT based on GCC 4.4, but > haven't done any real-time tests with it yet.) AFAIK it is still present in GNAT Pro 6.3.1, which is the latest version of GNAT. > This seems like an > unfortunate bug to have lying around in an otherwise respected > compiler. Yes, but in real-life applications it does not show itself, because tasking stuff somehow wakes the RTL up. That is probably the reason, I suggest, why none of paying customers had yet reported it to AdaCore. > BTW, my test results with -O3 and -Os, there is no difference in > performance between the two loops, and -Os produces code that is about > 33% faster than -O3. With -O0, the second loop is faster by an > average of 10%. I would have thought the extra conditional would have > been costlier. Niklas has posted an excellent comment regarding performance measures. It is quite difficult to do time measurements right in presence of -O2/3. As a small addition, here is a technique I am using to subtract looping overhead: T := Clock; for I in 1..N loop ... -- measured stuff end loop; D1 := Clock - T; T := Clock; for I in 1..N loop ... -- measured stuff ... -- measured stuff (do it twice) end loop; D2 := Clock - T; (D2 - D1) / N is the average time spent on measured stuff without the overhead caused by looping. Important, as Niklas has pointed out, to fool the compiler so, that it will not optimize out the things you are measuring... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de