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: a07f3367d7,3737542e2ed2b8e1 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news2.google.com!news.glorb.com!aioe.org!nospam From: "John B. Matthews" Newsgroups: comp.lang.ada Subject: Re: Problem with optimizations Date: Tue, 28 Apr 2009 15:15:47 -0400 Organization: The Wasteland Message-ID: References: <49f73730$0$2850$ba620e4c@news.skynet.be> <49f742d0$0$2851$ba620e4c@news.skynet.be> NNTP-Posting-Host: ib4TTflHUauJidfWP/+Rjw.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org NNTP-Posting-Date: Tue, 28 Apr 2009 19:16:01 +0000 (UTC) X-Notice: Filtered by postfilter v. 0.7.7 Cancel-Lock: sha1:l0doQNpRo1NLGT4LojRKYI+MqO4= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: g2news2.google.com comp.lang.ada:5591 Date: 2009-04-28T15:15:47-04:00 List-Id: In article <49f742d0$0$2851$ba620e4c@news.skynet.be>, Olivier Scalbert wrote: > Albrecht Käfer wrote: > > > Works fine on Windows (GNAT GPL 2009). > > However, I can't help but notice that you are doing premature > > optimization. Did you *test* if it is faster? > > > > > > Albrecht > > With -O3 also ? > > It is not premature optimization. The difference between Is_Solved and > Is_Solved1 is quite important on my system: > > with -O2 and Is_solved: > time ./rubikmain > real 0m2.164s > user 0m2.160s > sys 0m0.000s > > with -O2 and Is_solved[1]: > time ./rubikmain > real 0m3.604s > user 0m3.596s > sys 0m0.000s > > Olivier Using FSF-GNAT[1], I was able to reproduce the -O3 failure. This version of Is_Solved seems to work at -O3, and it is similarly faster: function Is_Solved(Cube: Cube_T) return Boolean is begin for i in Face_Index_T'range loop for j in Face_T'range(1) loop for k in Face_T'range(2) loop if Cube(i)(j,k) /= Final_Position(i)(j,k) then return False; end if; end loop; end loop; end loop; return True; end Is_Solved; This version of Is_Solved1 was not measurably faster: function Is_Solved1(Cube: Cube_T) return Boolean is begin return Cube = Final_Position; end Is_Solved1; [1] GNAT 4.3.4 20090225 (prerelease) [gcc-4_3-branch revision 143854] Copyright 1996-2007, Free Software Foundation, Inc. -- John B. Matthews trashgod at gmail dot com