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: 103376,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: 108717,a7c8692cac750b5e X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid115aec,gid108717,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newshub.sdsu.edu!tethys.csu.net!nntp.csufresno.edu!sn-xit-03!sn-xit-08!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: CTips Newsgroups: comp.lang.ada,comp.realtime,comp.programming,comp.software-eng Subject: Re: 10 rules for benchmarking (was Re: Teaching new tricks to an old dog (C++ -->Ada)) Date: Fri, 11 Mar 2005 21:33:42 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <1134l90ja5sqm73@corp.supernews.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <112rs0bdr2aftdf@corp.supernews.com> <1inxxr988rxgg$.1w9dedak41k89.dlg@40tude.net> <112s1r0rf0o8nca@corp.supernews.com> <112sonip5v4dca6@corp.supernews.com> <112t3de6fu04f38@corp.supernews.com> <1110396477.596174.285520@o13g2000cwo.googlegroups.com> <112vb2t8eonuhed@corp.supernews.com> <1110422108.925127.54110@o13g2000cwo.googlegroups.com> <11329cb96h2p19f@corp.supernews.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@supernews.com Xref: g2news1.google.com comp.lang.ada:9196 comp.realtime:1332 comp.programming:17850 comp.software-eng:4899 Date: 2005-03-11T21:33:42-05:00 List-Id: Jim Rogers wrote: > CTips wrote in > news:11329cb96h2p19f@corp.supernews.com: > > >>Since it appears that several people out here are making some very >>basic mistakes when they report benchmark numbers, I thought I'd write >>a small note on how to do benchmarking. >> > > [snip advice] > >>10. Make sure that your numbers are reproducible: report >> - your times >> - your hardware >> - your system >> * OS (with version) >> * compiler (with version) >> - the compiler flags used >> >> > > > Let's see if this helps. > I have adjusted my program to meet some of your advice. > The I/O at the end is not included in the reported timing. > The program now runs for > 1 second. Close, but still has one problem. You're using Ada.Calendar.Clock, which, IIRC, returns the actual wall-clock time. So, if you were swapped out in the middle, you would be over-reporting the time. Isn't there some Ada call that is the equivalent of POSIX clock() [or, better, times()]? If I look at your numbers, it seems that you using 2e-7 seconds per call. On a 2GHz AMD, that translates to 388 cycles per call. IIRC, the C codes that were posted to find the highest bit set thread were about 1/10th of that number. Just to double check, I wrote and measured some C code. On my 3GHz Xeon running with cygwin on WinXP, when compiled with gcc3.3.3 using -mpcu=i686 -O0, I got a total run-time of 2.3s, for about 69 cycles/iteration, and with -O2 I get 0.94s for about 28 cycles/iteration. We're comparing a Xeon with a AMD so its not apples to apples, but still, it suggests that either your timing methodology could use some work, or that the code generated is quite bad. unsigned FindHighestBit(unsigned n) { unsigned d = 0; if( n > 0xffff ) { d += 16; n >>= 16; } if( n > 0xff ) { d += 8; n >>= 8; } if( n > 0xf ) { d += 4; n >>= 4; } if( n > 0x3 ) { d += 2; n >>= 2; } if( n > 0x1 ) { d += 1; n >>= 1; } if( n > 0x0 ) { d += 1; } return d; } main(void) { unsigned i; unsigned j; unsigned s= 0; unsigned val[32]; for( i = 0; i < 32; i+= 2 ) { val[i] = (1U< > Time run: 1.94 seconds > Hardware: 2.0GHz AMD 64 processor with 512 Mb memory > System : > OS : WIN XP Service Pack 1 > compiler: GNAT v3.15p > Compiler flags: none (-O2 was tried but appeared to remove too much) > > Program: Performs bit search 10,000,000 times > > -- Highest bit set > with Ada.Text_Io; > with Ada.Calendar; use Ada.Calendar; > > procedure Highest_Bit_Set is > Num : Integer; > type Index_Type is mod 32; > type Bit_Array is array(Index_Type) of Boolean; > pragma Pack(Bit_Array); > Overlay : Bit_Array; > for Overlay'Address use Num'Address; > Start, Stop : Time; > Bit_Num : Index_Type := 0; > begin > Start := Clock; > Num := 1; > for X in 1..10_000_000 loop > for I in reverse Overlay'range loop > if Overlay(I) then > Bit_Num := I; > exit; > end if; > end loop; > end loop; > Stop := Clock; > Ada.Text_IO.Put_Line("High bit :" & Index_Type'Image(Bit_Num)); > Ada.Text_IO.Put_Line("Execution time: " & > Duration'Image(Stop - Start)); > end Highest_Bit_Set; > > Program output: > High bit : 0 > Execution time: 1.950221327 > > Jim Rogers > > >