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-Attributes: gid103376,gid115aec,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail From: "jimmaureenrogers@worldnet.att.net" Newsgroups: comp.lang.ada,comp.realtime Subject: Re: 10 rules for benchmarking (was Re: Teaching new tricks to an old dog (C++ -->Ada)) Date: 12 Mar 2005 23:06:34 -0800 Organization: http://groups.google.com Message-ID: <1110697594.374273.103230@z14g2000cwz.googlegroups.com> References: <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> <113394jjvppao64@corp.supernews.com> <1133s3qnmqmbjfb@corp.supernews.com> <4232a9f7$0$26552$9b4e6d93@newsread4.arcor-online.net> <11369p5jrcc6835@corp.supernews.com> <1137falp86qhk89@corp.supernews.com> NNTP-Posting-Host: 69.170.70.49 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1110697598 31800 127.0.0.1 (13 Mar 2005 07:06:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 13 Mar 2005 07:06:38 +0000 (UTC) In-Reply-To: <1137falp86qhk89@corp.supernews.com> User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: z14g2000cwz.googlegroups.com; posting-host=69.170.70.49; posting-account=SqOfxAwAAAAkL81YAPGH1JdBwpUXw9ZG Xref: g2news1.google.com comp.lang.ada:9292 comp.realtime:1408 Date: 2005-03-12T23:06:34-08:00 List-Id: CTips wrote: > Jim Rogers wrote: > > > CTips wrote in news:11369p5jrcc6835@corp.supernews.com: > > > > > >>Oh, and just to illustrate another point about Ada, try running the Ada > >>program equivalent to the following program: > >> > >>#define N 30000 > >>#define N2 60000 > >> > >>void > >>setup_array( > >> int * x[N2], > >> int p[N+1], > >> int q[N+1] > >> ) > >>{ > >> int i; > >> for( i = 0; i < N; i++ ) { > >> x[i] = &p[i]; > >> x[i+N] = &q[i]; > >> > >> } > >>} > > > > > > The function setup_array sets up the x array > > so that the first N elements each individually > > point to the elements of the p array, except for > > the last element in the p array. The second N > > elements of X point to the elements of the q > > array, except for the last element of the q > > array. > > > > > >>void > >>do_array( > >> int * x[N2] > >> ) > >>{ > >> int i; > >> int *p; > >> for( i = 0; i < N2; i++ ) { > >> p = x[i]; > >> p[1] = i; > >> } > >>} > > > > > > do_array has p point to the ith element in x, > > then treats p as an array and assigns its second > > element the value i. > > > > This sort of programming is generally foolishness. > > This is meant to bring a performance issue into sharp focus. Each > element of this program was picked specifically for that reason. Try > writing the *equivalent* Ada program and *benchmark* it. See what the > performance will be. > > The following elements are involved: > - I want an array of "handles"; that's why I picked a set of pointers. > - I want an array bounds check. Thats why the pointers are pointers to > unbounded arrays, and why there is a p[1]. I do not see any pointers to unbounded arrays. This is not using C99 dynamic arrays. It simply treats a pointer to int as a pointer to an unspecified sized array of int. This is done even though there is no such beast being pointed to at the time. Ada would not handle this with bounds checking at run time. The compiler would not allow this kind of activity. You will not demonstrate the speed of C over Ada. You have demonstrated the ability to misuse C constructs and complain when Ada does not allow the same kinds of misuse. > - I want the arrays to have a particular size; that is why I picked N as > 30000. > - I used two arrays p & q to inhibit a possible compiler optimization > (which is not very likely, but its nice to cover all the bases) > > The rest of setup_array and main are really there to make sure that the > right things happens, and that the function gets called the right number > of times. > > This is not intended to be a real program; it is meant to illustrate how > much slower Ada can get than C. Try and write it as specified and > measure the resulting performance. The program will not compile if I write it as specified. It is an erroneous program. Jim Rogers