From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: 'Base
Date: Thu, 15 Dec 2005 21:08:22 +0100
Date: 2005-12-15T21:08:22+01:00 [thread overview]
Message-ID: <1442266.RLM9APbJWj@linux1.krischik.com> (raw)
In-Reply-To: bB_nf.15339$fi4.1728@newsfe10.ams
Per Sandberg wrote:
> Ole-Hjalmar Kristensen wrote:
>> My gut reaction was also that Ada will always outperform Java, but I
>> have found at least one case there this is not true. I recently wrote
>> a simple test program to transpose a two-dimensional array in Java,
>> Ada, C++, and C. The purpose was not really to compare languages, but
>> to see the effects of caching. There were two different alogrithms
>> used, one a simple nested loop, the other a recursive subdivision with
>> a nested loop at the lowest level. When the simple nested loop was
>> tested with large data sets (~ available RAM on the machines) the
>> diffence between Ada, C, and C++ was insignificant, all being 3-4
>> times faster than Java. However, when testing the recursive version, I
>> found that Java was actually about 10% faster than the other three,
>> which again came extremely close to each other. Apparently the JIT
>> compiler had plenty of time to do its work and come up with pretty
>> optimal code. The other interesting result from the experiment was
>> that the recursive version was from 3-4 to 20 times faster than the
>> simple nested loop.
>>
>>
>>
>>>>>>>"MK" == Martin Krischik <krischik@users.sourceforge.net> writes:
>>
>> <snip>
>> MK> Ada arrays are not a primitive type - they are a quite complex
>> and powerfull MK> type.
>>
>> MK> Performace? Ada allways outperform Java for a start. But Ada's
>> build in MK> checks will also outperform C/C++ when used with all
>> appropriate MK> "assert()"s in place.
>>
>> <snip>
>
> This is intresting but i have tried Ada (GNAT/GCC) with different
> optimisation levels and different validity checking.
> and fount that ther is a clearly visible diference in performance
> depending on how far the compiler is allowed to go in terms of
> optimisation. I have not done any qualified measurments but the guts
> feeling is that the performace may change bye a factor of at least 2
> depending on compiler switches.
> Also worth to mention that as far as i have seen ther is normaly areound
> 30% difference in performace when going from "-O0" to "-Os".
Sure - if you switch checks off and optimization on the program will be
faster.
If you compare Ada - with checks - with C/C++ - with assert then Ada will
have more change in optimization of those checks then C/C++ has on the
asserts.
Ada:
type X is range ...
f (Value : X) is ....
for I in X'Range loop
f (i);
end loop;
C:
typedef int X;
extern f (X Value)
{
assert (Value >= X_First && Value <= X_Last)
.....
}
for (i= X_First ; X <= X_Last; i++)
{
f (i);
}
Ada will make no checks at all while in C must check "Value" with each loop.
Remember: we live in a complex world and f () will be called a different
places - some where static analysis may prove the correctness of t the
parameter - like the example above - and some where it cant. Just removing
the assert is not an option.
Martin
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
next prev parent reply other threads:[~2005-12-15 20:08 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-08 15:21 'Base ada_student
2005-12-08 18:08 ` 'Base Matthew Heaney
2005-12-08 18:44 ` 'Base Martin Dowie
2005-12-08 18:49 ` 'Base Martin Dowie
2005-12-08 19:24 ` 'Base Matthew Heaney
2005-12-08 20:27 ` 'Base Martin Dowie
2005-12-08 19:51 ` 'Base Jeffrey R. Carter
2005-12-08 20:07 ` 'Base Matthew Heaney
2005-12-09 2:57 ` 'Base Randy Brukardt
2005-12-09 2:13 ` Avoiding constraint checks w/ 'Base Anonymous Coward
2005-12-09 3:11 ` Randy Brukardt
2005-12-09 13:11 ` 'Base krischik
2005-12-09 13:52 ` 'Base Matthew Heaney
2005-12-09 20:42 ` 'Base Randy Brukardt
2005-12-08 19:11 ` 'Base Martin Krischik
2005-12-09 20:42 ` 'Base ada_student
2005-12-09 21:39 ` 'Base Pascal Obry
2005-12-10 3:30 ` 'Base Matthew Heaney
2005-12-10 14:50 ` 'Base ada_student
2005-12-10 7:52 ` 'Base Martin Krischik
2005-12-10 12:55 ` 'Base Larry Kilgallen
2005-12-10 13:37 ` 'Base Björn Persson
2005-12-11 11:00 ` 'Base Martin Krischik
2005-12-10 15:01 ` 'Base Robert A Duff
2005-12-11 10:59 ` 'Base Martin Krischik
2005-12-12 9:14 ` 'Base Ole-Hjalmar Kristensen
2005-12-12 19:08 ` 'Base Martin Krischik
2005-12-13 19:24 ` 'Base tmoran
2005-12-13 21:00 ` 'Base Georg Bauhaus
2005-12-14 19:43 ` 'Base Per Sandberg
2005-12-15 20:08 ` Martin Krischik [this message]
2005-12-16 19:19 ` 'Base Jeffrey R. Carter
2005-12-17 7:52 ` 'Base Martin Krischik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox