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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d575f572a099528 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-07 08:50:24 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!128.39.3.168!uninett.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: What is faster Ada or C? Date: Fri, 7 Dec 2001 16:50:19 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: References: <3c08314d$0$158$9b622d9e@news.freenet.de> <3C0BA624.7A12BFA1@boeing.com> <3C10C26B.AA451459@nbi.dk> NNTP-Posting-Host: kiuk0156.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1007743819 11356 129.241.83.82 (7 Dec 2001 16:50:19 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Fri, 7 Dec 2001 16:50:19 +0000 (UTC) User-Agent: slrn/0.9.7.3 (Linux) Xref: archiver1.google.com comp.lang.ada:17580 Date: 2001-12-07T16:50:19+00:00 List-Id: On 07 Dec 2001 17:16:18 +0200, Aaro Koskinen wrote: > Jacob Sparre Andersen writes: >> * Why are the two programs below not equivalent? >> * How can I get the Ada program to run as fast as the C++ program? > [..] >> Compilation...: gnatmake sqrt_timer -O3 -gnatn > [..] >> for i in 1 .. 10_000_000 loop >> X := Sqrt (1.0 + X); >> end loop; > > Did you try with -gnatp? I tried to add the -gnatp switch. I compiled the Ada programs twice with the -O3 and -S switches. Whether I add the -gnatp switch or not I get the exact same assambler source. Is this correct? I think the difference between the Ada and C++ program is the Sqrt function. The assembler source for the ada program is about 2000 lines while the C++ source is around 100. Note that the gcc compiler Ada (GNAT) uses is 2.8.1 while the g++ I have is 2.95 and 3.0 (unfortunately not 2.8.1). The execution time are 615ms for the 2.95 while 1041ms for 3.0. So the gcc compiler also plays a role. I simplified the two programs by removing sqrt (and using Float in Ada) and then both programs run at the same speed, 66ms. Preben -- () Join the worldwide campaign to protect fundamental human rights. '||} {||' http://www.amnesty.org/