* ada is getting spanked :(
@ 2006-10-28 16:29 cl1
2006-10-28 17:45 ` Martin Krischik
` (2 more replies)
0 siblings, 3 replies; 44+ messages in thread
From: cl1 @ 2006-10-28 16:29 UTC (permalink / raw)
I just got wind of this site. It would seem that ada, while not at
the very bottom, is one of the slowest languages in this benchmark
competition:
http://shootout.alioth.debian.org
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-28 16:29 ada is getting spanked :( cl1
@ 2006-10-28 17:45 ` Martin Krischik
2006-10-28 20:02 ` Georg Bauhaus
` (4 more replies)
2006-10-28 22:45 ` ada is getting spanked :( Larry Kilgallen
2006-10-29 16:22 ` Leif Holmgren
2 siblings, 5 replies; 44+ messages in thread
From: Martin Krischik @ 2006-10-28 17:45 UTC (permalink / raw)
cl1 wrote:
> I just got wind of this site. It would seem that ada, while not at
> the very bottom, is one of the slowest languages in this benchmark
> competition:
>
> http://shootout.alioth.debian.org
Looks worse then last time I looked. Seems that some language advocates
really optimised there implementations.
And there is still one test missing for Ada.
Martin
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-28 17:45 ` Martin Krischik
@ 2006-10-28 20:02 ` Georg Bauhaus
2006-10-29 1:34 ` Georg Bauhaus
` (3 subsequent siblings)
4 siblings, 0 replies; 44+ messages in thread
From: Georg Bauhaus @ 2006-10-28 20:02 UTC (permalink / raw)
On Sat, 2006-10-28 at 19:45 +0200, Martin Krischik wrote:
> cl1 wrote:
>
> > I just got wind of this site. It would seem that ada, while not at
> > the very bottom, is one of the slowest languages in this benchmark
> > competition:
> >
> > http://shootout.alioth.debian.org
>
> Looks worse then last time I looked. Seems that some language advocates
> really optimised there implementations.
Don't think so, a more recent GNAT's output is speeding
up, almost keeping pace. For example, comparing the C and Ada versions
of the terribly recursive program using GCC 4.2 on -march=pentium,
the C advantage shrinks: 6.7s (C) : 7.3s (Ada).
The Debian / AMD listing shows 2.68 : 4.00,
the Gentoo / P4 listing shows 2.63 : 10.61
This says something about the volatility of speed comparisons
(probably documented on site). :-)
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-28 16:29 ada is getting spanked :( cl1
2006-10-28 17:45 ` Martin Krischik
@ 2006-10-28 22:45 ` Larry Kilgallen
2006-10-29 16:22 ` Leif Holmgren
2 siblings, 0 replies; 44+ messages in thread
From: Larry Kilgallen @ 2006-10-28 22:45 UTC (permalink / raw)
In article <1162052997.664967.135910@e3g2000cwe.googlegroups.com>, "cl1" <charles.w.lambert@gmail.com> writes:
> I just got wind of this site. It would seem that ada, while not at
> the very bottom, is one of the slowest languages in this benchmark
> competition:
>
> http://shootout.alioth.debian.org
It is not possible to measure the speed of a language, only the speed
of an implementation.
The position you ascribe to Ada actually belongs to GNAT.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-28 17:45 ` Martin Krischik
2006-10-28 20:02 ` Georg Bauhaus
@ 2006-10-29 1:34 ` Georg Bauhaus
2006-10-29 2:13 ` Jeffrey R. Carter
` (3 more replies)
2006-10-29 4:58 ` Isaac Gouy
` (2 subsequent siblings)
4 siblings, 4 replies; 44+ messages in thread
From: Georg Bauhaus @ 2006-10-29 1:34 UTC (permalink / raw)
On Sat, 2006-10-28 at 19:45 +0200, Martin Krischik wrote:
> > http://shootout.alioth.debian.org
>
> Looks worse then last time I looked. Seems that some language advocates
> really optimised there implementations.
In order to optimize GNAT's standing, I have made a small
but quite effective change to one of Jim Rogers' programs
(regex-dna #2), the factor is 14 (fourteen). Nothing submitted
yet, please use this as a starting point if you like.
See here, under the heading Shootout:
http://home.arcor.de/bauhaus/Ada/
I have some more ideas but cannot try them right now.
regards,
Georg Bauhaus
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 1:34 ` Georg Bauhaus
@ 2006-10-29 2:13 ` Jeffrey R. Carter
2006-10-29 4:48 ` Isaac Gouy
2006-10-29 2:26 ` Jeffrey R. Carter
` (2 subsequent siblings)
3 siblings, 1 reply; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-10-29 2:13 UTC (permalink / raw)
Georg Bauhaus wrote:
>
> In order to optimize GNAT's standing, I have made a small
> but quite effective change to one of Jim Rogers' programs
> (regex-dna #2), the factor is 14 (fourteen). Nothing submitted
> yet, please use this as a starting point if you like.
I've found a small change that improves the nsieve program (also Jim
Rogers). Change the line
S (I) := False;
to
if S (I) then
S (I) := False;
end if;
on my computer (3.2 GHz Pentium 4 HT), compiled with MinGW GNAT 3.4.2 with
-O3 -gnatnp -march=pentium4 -fomit-frame-pointer
the time was reduced from about 1.8 s for the original to about 1.1 s
with this modification, a speedup of 38.9%. Applied to the 2.71 s
reported time, that would give GNAT 1.66 s, which would move it to 3rd
place.
I hope no one thinks we're picking on Jim.
--
Jeff Carter
"Your mother was a hamster and your father smelt of elderberries."
Monty Python & the Holy Grail
06
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 1:34 ` Georg Bauhaus
2006-10-29 2:13 ` Jeffrey R. Carter
@ 2006-10-29 2:26 ` Jeffrey R. Carter
2006-10-29 2:30 ` Jeffrey R. Carter
2006-10-29 8:54 ` Martin Krischik
2006-10-29 16:27 ` Björn Persson
3 siblings, 1 reply; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-10-29 2:26 UTC (permalink / raw)
For the Nsieve problem, is there any reason not to do it like this:
-- The Great Computer Language Shootout
-- http://shootout.alioth.debian.org/
--
-- Contributed by Jim Rogers
-- Modified by Jeffrey R. Carter
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Nsieve is
procedure Count (N : in Natural) is
M : constant Natural := 2 ** N * 10_000;
type Boolean_Array is array (2 .. M) of Boolean;
M2 : constant Natural := M / 2;
M3 : constant Natural := M2 / 2;
C1 : Natural := 0;
C2 : Natural := 0;
C3 : Natural := 0;
S : Boolean_Array := (others => True);
I : Positive;
begin -- Count
for K in S'Range loop
if S (K) then
C1 := C1 + 1;
I := K + K;
if I <= M2 then
C2 := C2 + 1;
if I <= M3 then
C3 := C3 + 1;
end if;
end if;
while I <= M loop
if S (I) then
S (I) := False;
end if;
I := I + K;
end loop;
end if;
end loop;
Put ("Primes up to ");
Put (Item => M, Width => 8);
Put (" ");
Put (Item => C1, Width => 8);
New_Line;
Put ("Primes up to ");
Put (Item => M2, Width => 8);
Put (" ");
Put (Item => C2, Width => 8);
New_Line;
Put ("Primes up to ");
Put (Item => M3, Width => 8);
Put (" ");
Put (Item => C3, Width => 8);
New_Line;
end Count;
N : constant Natural := Natural'Value (Argument (1) );
begin -- Nsieve
Count (N);
end Nsieve;
?
This is much faster (0.6 s on my machine, which gave about 1.8 s for the
existing version), and should put us in 1st place.
--
Jeff Carter
"Your mother was a hamster and your father smelt of elderberries."
Monty Python & the Holy Grail
06
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 2:26 ` Jeffrey R. Carter
@ 2006-10-29 2:30 ` Jeffrey R. Carter
2006-10-29 2:33 ` Jeffrey R. Carter
0 siblings, 1 reply; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-10-29 2:30 UTC (permalink / raw)
Jeffrey R. Carter wrote:
Minor correction. Change
> I := K + K;
>
> if I <= M2 then
> C2 := C2 + 1;
>
> if I <= M3 then
> C3 := C3 + 1;
> end if;
> end if;
>
> while I <= M loop
to
> if I <= M2 then
> C2 := C2 + 1;
>
> if I <= M3 then
> C3 := C3 + 1;
> end if;
> end if;
>
> I := K + K;
>
> while I <= M loop
--
Jeff Carter
"Your mother was a hamster and your father smelt of elderberries."
Monty Python & the Holy Grail
06
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 2:30 ` Jeffrey R. Carter
@ 2006-10-29 2:33 ` Jeffrey R. Carter
2006-10-29 17:19 ` Jeffrey R. Carter
2006-10-29 17:25 ` Jeffrey R. Carter
0 siblings, 2 replies; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-10-29 2:33 UTC (permalink / raw)
Jeffrey R. Carter wrote:
I'm not thinking very well tonight. Make that
> > if K <= M2 then
> > C2 := C2 + 1;
> >
> > if K <= M3 then
> > C3 := C3 + 1;
> > end if;
> > end if;
> >
> > I := K + K;
> >
> > while I <= M loop
I apologize for any confusion. The timings remain the same.
--
Jeff Carter
"Your mother was a hamster and your father smelt of elderberries."
Monty Python & the Holy Grail
06
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 2:13 ` Jeffrey R. Carter
@ 2006-10-29 4:48 ` Isaac Gouy
2006-10-30 1:01 ` Isaac Gouy
0 siblings, 1 reply; 44+ messages in thread
From: Isaac Gouy @ 2006-10-29 4:48 UTC (permalink / raw)
Jeffrey R. Carter wrote:
> Georg Bauhaus wrote:
> >
> > In order to optimize GNAT's standing, I have made a small
> > but quite effective change to one of Jim Rogers' programs
> > (regex-dna #2), the factor is 14 (fourteen). Nothing submitted
> > yet, please use this as a starting point if you like.
>
> I've found a small change that improves the nsieve program (also Jim
> Rogers). Change the line
>
> S (I) := False;
>
> to
>
> if S (I) then
> S (I) := False;
> end if;
>
> on my computer (3.2 GHz Pentium 4 HT), compiled with MinGW GNAT 3.4.2 with
>
> -O3 -gnatnp -march=pentium4 -fomit-frame-pointer
>
> the time was reduced from about 1.8 s for the original to about 1.1 s
> with this modification, a speedup of 38.9%. Applied to the 2.71 s
> reported time, that would give GNAT 1.66 s, which would move it to 3rd
> place.
>
> I hope no one thinks we're picking on Jim.
>
> --
> Jeff Carter
> "Your mother was a hamster and your father smelt of elderberries."
> Monty Python & the Holy Grail
> 06
Thanks for the reminder that I should throwout/fix the programs that
use a test to avoid doing what the benchmark description asks them to
do :-)
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-28 17:45 ` Martin Krischik
2006-10-28 20:02 ` Georg Bauhaus
2006-10-29 1:34 ` Georg Bauhaus
@ 2006-10-29 4:58 ` Isaac Gouy
2006-10-29 8:46 ` Martin Krischik
2006-10-30 18:26 ` jtg
2006-11-12 22:26 ` Shootout / pidigits [Re: ada is getting spanked :(] Gautier
4 siblings, 1 reply; 44+ messages in thread
From: Isaac Gouy @ 2006-10-29 4:58 UTC (permalink / raw)
Martin Krischik wrote:
> cl1 wrote:
>
> > I just got wind of this site. It would seem that ada, while not at
> > the very bottom, is one of the slowest languages in this benchmark
> > competition:
> >
> > http://shootout.alioth.debian.org
>
> Looks worse then last time I looked. Seems that some language advocates
> really optimised there implementations.
>
> And there is still one test missing for Ada.
>
> Martin
> --
> mailto://krischik@users.sourceforge.net
> Ada programming at: http://ada.krischik.com
The positions for the compiled languages shuffled around a bit after we
made an effort to use the same gcc compiler options on all the language
implementations that would take them.
And at least on Gentoo, after upgrading to gcc 4.1.1 I'm not that sure
which version of GNAT we should be using?
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 4:58 ` Isaac Gouy
@ 2006-10-29 8:46 ` Martin Krischik
2006-10-30 0:17 ` Isaac Gouy
0 siblings, 1 reply; 44+ messages in thread
From: Martin Krischik @ 2006-10-29 8:46 UTC (permalink / raw)
Isaac Gouy wrote:
>
> Martin Krischik wrote:
>> cl1 wrote:
>>
>> > I just got wind of this site. It would seem that ada, while not at
>> > the very bottom, is one of the slowest languages in this benchmark
>> > competition:
>> >
>> > http://shootout.alioth.debian.org
>>
>> Looks worse then last time I looked. Seems that some language advocates
>> really optimised there implementations.
>>
>> And there is still one test missing for Ada.
>>
>> Martin
>> --
>> mailto://krischik@users.sourceforge.net
>> Ada programming at: http://ada.krischik.com
>
> The positions for the compiled languages shuffled around a bit after we
> made an effort to use the same gcc compiler options on all the language
> implementations that would take them.
I see. perhaps we should have a look at the options used for Ada - there are
a few performace options for GNAT only.
> And at least on Gentoo, after upgrading to gcc 4.1.1 I'm not that sure
> which version of GNAT we should be using?
4.1.* is usually good for Ada - and as we recently found out improves
performance as well.
Martin
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 1:34 ` Georg Bauhaus
2006-10-29 2:13 ` Jeffrey R. Carter
2006-10-29 2:26 ` Jeffrey R. Carter
@ 2006-10-29 8:54 ` Martin Krischik
2006-10-29 13:01 ` Georg Bauhaus
2006-10-29 16:27 ` Björn Persson
3 siblings, 1 reply; 44+ messages in thread
From: Martin Krischik @ 2006-10-29 8:54 UTC (permalink / raw)
Georg Bauhaus wrote:
> On Sat, 2006-10-28 at 19:45 +0200, Martin Krischik wrote:
>
>> > http://shootout.alioth.debian.org
>>
>> Looks worse then last time I looked. Seems that some language advocates
>> really optimised there implementations.
>
> In order to optimize GNAT's standing, I have made a small
> but quite effective change to one of Jim Rogers' programs
> (regex-dna #2), the factor is 14 (fourteen). Nothing submitted
> yet, please use this as a starting point if you like.
>
> See here, under the heading Shootout:
> http://home.arcor.de/bauhaus/Ada/
>
> I have some more ideas but cannot try them right now.
Wikibooks Ada - the sourceforce project [1] has a place for the shootout [2]
code. Having the code inside a Subversion archive means we can colaborate.
And one can use the resulting code as example repository for the book ;-).
Martin
[1] http://wikibook-ada.sourceforge.net/
[2]
http://wikibook-ada.svn.sourceforge.net/viewvc/wikibook-ada/trunk/demos/Source/Language_Shootout
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 8:54 ` Martin Krischik
@ 2006-10-29 13:01 ` Georg Bauhaus
2006-10-30 0:46 ` Isaac Gouy
0 siblings, 1 reply; 44+ messages in thread
From: Georg Bauhaus @ 2006-10-29 13:01 UTC (permalink / raw)
Martin Krischik wrote:
> Georg Bauhaus wrote:
>> See here, under the heading Shootout:
>> http://home.arcor.de/bauhaus/Ada/
>>
>> I have some more ideas but cannot try them right now.
>
> Wikibooks Ada - the sourceforce project [1] has a place for the shootout [2]
> code. Having the code inside a Subversion archive means we can colaborate.
> And one can use the resulting code as example repository for the book ;-).
> http://wikibook-ada.svn.sourceforge.net/viewvc/wikibook-ada/trunk/demos/Source/Language_Shootout
OK, let's build the cathedral, a good one. However, this particular
program isn't mine, I'd not want to say where it goes, license permitting
or not. The source mentioned above is put there for the sake of this
discussion. It is supposed to vanish later. Surely I hope to see it as part.
BTW, is there a way to retrieve old contributions to the Shootout?
I remember some very elegant programs for example in ML that
I can no longer find there.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-28 16:29 ada is getting spanked :( cl1
2006-10-28 17:45 ` Martin Krischik
2006-10-28 22:45 ` ada is getting spanked :( Larry Kilgallen
@ 2006-10-29 16:22 ` Leif Holmgren
2006-10-29 17:28 ` Simon Wright
2006-10-29 19:21 ` jtg
2 siblings, 2 replies; 44+ messages in thread
From: Leif Holmgren @ 2006-10-29 16:22 UTC (permalink / raw)
cl1 wrote:
> I just got wind of this site. It would seem that ada, while not at
> the very bottom, is one of the slowest languages in this benchmark
> competition:
So what?
Has anyone ever tried to measure the important programming language
speed aspects? What I mean is
- Time to implement a complex algo by an average programmer, including
bug-fixing.
- Time for an average programmer to understand the code written for a
complex algorithm?
- Same stuff for complex control system.
These are the issues that are important, not that the execution speed is
of no importance, but for most of my software I don't care if it takes
1us or 1ms to open a hydraulic valve, but it sure has to happen.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 1:34 ` Georg Bauhaus
` (2 preceding siblings ...)
2006-10-29 8:54 ` Martin Krischik
@ 2006-10-29 16:27 ` Björn Persson
2006-10-29 20:23 ` Georg Bauhaus
2006-10-31 18:01 ` Martin Krischik
3 siblings, 2 replies; 44+ messages in thread
From: Björn Persson @ 2006-10-29 16:27 UTC (permalink / raw)
Georg Bauhaus wrote:
> In order to optimize GNAT's standing, I have made a small
> but quite effective change to one of Jim Rogers' programs
> (regex-dna #2), the factor is 14 (fourteen).
Ah, the one that uses Spitbol. Doesn't it really belong under
"interesting alternative programs"? The requirements clearly state that
regular expressions should be used.
I fixed up the regex version some time ago and achieved a dramatic
improvement, but I didn't touch the Spitbol version. They were very
similar before that, and as I recall they had similar performance too.
My changes are now in "regex-dna Ada 95 GNAT #3".
--
Bj�rn Persson PGP key A88682FD
omb jor ers @sv ge.
r o.b n.p son eri nu
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 2:33 ` Jeffrey R. Carter
@ 2006-10-29 17:19 ` Jeffrey R. Carter
2006-10-29 17:25 ` Jeffrey R. Carter
1 sibling, 0 replies; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-10-29 17:19 UTC (permalink / raw)
Another source of speedup for the nsieve program is to pack the array
type. We're still dealing directly with Booleans, so I don't see that
this is not allowed by the benchmark description.
--
Jeff Carter
"I'm a kike, a yid, a heebie, a hook nose! I'm Kosher,
Mum! I'm a Red Sea pedestrian, and proud of it!"
Monty Python's Life of Brian
77
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 2:33 ` Jeffrey R. Carter
2006-10-29 17:19 ` Jeffrey R. Carter
@ 2006-10-29 17:25 ` Jeffrey R. Carter
1 sibling, 0 replies; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-10-29 17:25 UTC (permalink / raw)
Also for nsieve, M is defined to be a multiple of 2, and so we know it
is not prime. We can omit it from consideration by changing the loop
condition to
while I < M loop
This is done by the C++ program in 2nd place, for example:
for (size_t i=2; i<m; ++i)
if (isPrime[i])
{
for(size_t k=i*2; k<m; k+=i)
isPrime[k] = false;
++count;
}
which only looks at 2 .. M - 1.
I don't expect much of an improvement from this, though.
--
Jeff Carter
"I'm a kike, a yid, a heebie, a hook nose! I'm Kosher,
Mum! I'm a Red Sea pedestrian, and proud of it!"
Monty Python's Life of Brian
77
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 16:22 ` Leif Holmgren
@ 2006-10-29 17:28 ` Simon Wright
2006-10-29 19:21 ` jtg
1 sibling, 0 replies; 44+ messages in thread
From: Simon Wright @ 2006-10-29 17:28 UTC (permalink / raw)
Leif Holmgren <nobody@nowhere.com> writes:
> cl1 wrote:
>> I just got wind of this site. It would seem that ada, while not at
>> the very bottom, is one of the slowest languages in this benchmark
>> competition:
>
> So what?
>
> Has anyone ever tried to measure the important programming language
> speed aspects? What I mean is
> - Time to implement a complex algo by an average programmer, including
> bug-fixing.
> - Time for an average programmer to understand the code written for a
> complex algorithm?
> - Same stuff for complex control system.
>
> These are the issues that are important, not that the execution
> speed is of no importance, but for most of my software I don't care
> if it takes 1us or 1ms to open a hydraulic valve, but it sure has to
> happen.
I agree, though my current project is the sort in which it _must not_
take more than 1 ms!
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 16:22 ` Leif Holmgren
2006-10-29 17:28 ` Simon Wright
@ 2006-10-29 19:21 ` jtg
2006-10-29 21:33 ` Leif Holmgren
1 sibling, 1 reply; 44+ messages in thread
From: jtg @ 2006-10-29 19:21 UTC (permalink / raw)
Leif Holmgren wrote:
> Has anyone ever tried to measure the important programming language
> speed aspects? What I mean is
> - Time to implement a complex algo by an average programmer, including
> bug-fixing.
There is one natural environment for such tests: programming
competition. For example at topcoder (www.topcoder.com) you can see some
statistics (average coding time, best coding time, correct programs
percentage etc.) for several languages used in these competitions.
Unfortunately, the languages are only C++, C#, java and Visual Basic.
> - Time for an average programmer to understand the code written for a
> complex algorithm?
At TopCoder there is a "challenge phase", when you can look into other
contestants' programs, look for bugs, and prepare a test case to prove
the program is incorrect.
There is also a "system test phase" to catch the bugs not found by
contestants.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 16:27 ` Björn Persson
@ 2006-10-29 20:23 ` Georg Bauhaus
2006-10-29 23:50 ` Björn Persson
2006-10-31 18:01 ` Martin Krischik
1 sibling, 1 reply; 44+ messages in thread
From: Georg Bauhaus @ 2006-10-29 20:23 UTC (permalink / raw)
On Sun, 2006-10-29 at 16:27 +0000, Björn Persson wrote:
> Georg Bauhaus wrote:
> > In order to optimize GNAT's standing, I have made a small
> > but quite effective change to one of Jim Rogers' programs
> > (regex-dna #2), the factor is 14 (fourteen).
The speed factor is now close to 18 :-). After some simplifications,
and after (I think) more closely reflecting the benchmark description.
http://home.arcor.de/bauhaus/Ada/
The program now also works more like the others (in my view).
> Ah, the one that uses Spitbol. Doesn't it really belong under
> "interesting alternative programs"? The requirements clearly state that
> regular expressions should be used.
The pattern strings in all programs all look regular to me,
including the GNAT.SPITBOL ones. But that doesn't mean
that the various programs' calls to RE routines such as
.findall, -all, m//g global subst(...) etc. imply "normal"
naive regular expression processing. So GNAT.SPITBOL is no
exception here. (In particular, I have left out obvious
standard SPITBOL improvements in order to reflect the benchmark
description.)
I guess that the benchmark is also about how well an
implementation deals with just simple REs.
Anyway, I think that all of the RE, PCRE, and SPITBOL patterns
I've seen in many of the contributions reflect the spirit of the
benchmark, as is required (literally).
How could a notion of REs be both precise and precisely
applicable to the ways in which various PLs implement them?
E.g. how can you turn off Boyer-Moore string searching when
one implementation has it, just so that only some specified
internal way of pattern matching is compared?
So my rule was: Simple patterns, no tricks.
> I fixed up the regex version some time ago and achieved a dramatic
> improvement, but I didn't touch the Spitbol version. They were very
> similar before that, and as I recall they had similar performance too.
> My changes are now in "regex-dna Ada 95 GNAT #3".
I did have a look at this program, however with program #3 as is
I keep getting segmentation faults due to the
Sequence_Lines (1 .. 1_000_000) of type Unbounded_String.
ulimit -s 10000 didn't help, reducing the number of lines did.
regards,
Georg
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 19:21 ` jtg
@ 2006-10-29 21:33 ` Leif Holmgren
2006-10-31 11:04 ` Harald Korneliussen
0 siblings, 1 reply; 44+ messages in thread
From: Leif Holmgren @ 2006-10-29 21:33 UTC (permalink / raw)
jtg wrote:
> Leif Holmgren wrote:
>
>> Has anyone ever tried to measure the important programming language
>> speed aspects? What I mean is
>> - Time to implement a complex algo by an average programmer, including
>> bug-fixing.
>
>
> There is one natural environment for such tests: programming
> competition. For example at topcoder (www.topcoder.com) you can see some
> statistics (average coding time, best coding time, correct programs
> percentage etc.) for several languages used in these competitions.
> Unfortunately, the languages are only C++, C#, java and Visual Basic.
>
Without having looked I believe the problem is that such sites will only
attract the really talented programmers. And a talented programmer can
write fortran in any programming language.
What's really interesting is the result from those coders that go home
after their 8 hours in front of the terminal and dont spend five minutes
thinking about software until they are back at work the next day.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 20:23 ` Georg Bauhaus
@ 2006-10-29 23:50 ` Björn Persson
2006-10-31 11:32 ` Dmitry A. Kazakov
0 siblings, 1 reply; 44+ messages in thread
From: Björn Persson @ 2006-10-29 23:50 UTC (permalink / raw)
Georg Bauhaus wrote:
> The speed factor is now close to 18 :-). After some simplifications,
> and after (I think) more closely reflecting the benchmark description.
You're probably going to beat #3, because Gnat.Spitbol works with
unbounded strings but Gnat.Regpat requires fixed strings.
> How could a notion of REs be both precise and precisely
> applicable to the ways in which various PLs implement them?
> E.g. how can you turn off Boyer-Moore string searching when
> one implementation has it, just so that only some specified
> internal way of pattern matching is compared?
I wasn't talking of internal implementations. As I understand it,
"regex" is a name of a family of similar notations for expressing
patterns. If you don't write "[ABC]*" for "any number of A's, B's and
C's in any order", then it isn't regex.
The requirement to use one particular pattern notation may of course be
unintentional. Maybe the person who wrote the requirements didn't know
that other notations existed.
> I did have a look at this program, however with program #3 as is
> I keep getting segmentation faults due to the
>
> Sequence_Lines (1 .. 1_000_000) of type Unbounded_String.
>
> ulimit -s 10000 didn't help, reducing the number of lines did.
Now that you mention it, I remember having that problem too. I didn't
change that part, and as it had obviously worked on the contest servers
I figured it should keep working there. I suppose #2 falls below that
limit on your box because it calculates how big the array needs to be.
--
Björn Persson PGP key A88682FD
omb jor ers @sv ge.
r o.b n.p son eri nu
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 8:46 ` Martin Krischik
@ 2006-10-30 0:17 ` Isaac Gouy
0 siblings, 0 replies; 44+ messages in thread
From: Isaac Gouy @ 2006-10-30 0:17 UTC (permalink / raw)
Martin Krischik wrote:
> Isaac Gouy wrote:
>
> >
> > Martin Krischik wrote:
> >> cl1 wrote:
> >>
> >> > I just got wind of this site. It would seem that ada, while not at
> >> > the very bottom, is one of the slowest languages in this benchmark
> >> > competition:
> >> >
> >> > http://shootout.alioth.debian.org
> >>
> >> Looks worse then last time I looked. Seems that some language advocates
> >> really optimised there implementations.
> >>
> >> And there is still one test missing for Ada.
> >>
> >> Martin
> >> --
> >> mailto://krischik@users.sourceforge.net
> >> Ada programming at: http://ada.krischik.com
> >
> > The positions for the compiled languages shuffled around a bit after we
> > made an effort to use the same gcc compiler options on all the language
> > implementations that would take them.
>
> I see. perhaps we should have a look at the options used for Ada - there are
> a few performace options for GNAT only.
>
> > And at least on Gentoo, after upgrading to gcc 4.1.1 I'm not that sure
> > which version of GNAT we should be using?
>
> 4.1.* is usually good for Ada - and as we recently found out improves
> performance as well.
>
> Martin
> --
> mailto://krischik@users.sourceforge.net
> Ada programming at: http://ada.krischik.com
The Gentoo/Intel website has now been updated, and the Ada measurements
are for GNAT 4.1.1
There were several small performance improvements but the largest
improvement was for recursive.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 13:01 ` Georg Bauhaus
@ 2006-10-30 0:46 ` Isaac Gouy
0 siblings, 0 replies; 44+ messages in thread
From: Isaac Gouy @ 2006-10-30 0:46 UTC (permalink / raw)
Georg Bauhaus wrote:
-snip-
> BTW, is there a way to retrieve old contributions to the Shootout?
> I remember some very elegant programs for example in ML that
> I can no longer find there.
No. However if the programs were contributed in the normal way they
will still be in the "Contribute Programs" tracker system - provided by
Alioth GForge. Unhappily those webpages have been "improved" in the
past few days and now you have to - 1) Login 2) Build and save a query
- before you can seach on a specific "language implementation" category
like SML or MLton.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 4:48 ` Isaac Gouy
@ 2006-10-30 1:01 ` Isaac Gouy
0 siblings, 0 replies; 44+ messages in thread
From: Isaac Gouy @ 2006-10-30 1:01 UTC (permalink / raw)
Isaac Gouy wrote:
> Jeffrey R. Carter wrote:
> > Georg Bauhaus wrote:
> > >
> > > In order to optimize GNAT's standing, I have made a small
> > > but quite effective change to one of Jim Rogers' programs
> > > (regex-dna #2), the factor is 14 (fourteen). Nothing submitted
> > > yet, please use this as a starting point if you like.
> >
> > I've found a small change that improves the nsieve program (also Jim
> > Rogers). Change the line
> >
> > S (I) := False;
> >
> > to
> >
> > if S (I) then
> > S (I) := False;
> > end if;
> >
> > on my computer (3.2 GHz Pentium 4 HT), compiled with MinGW GNAT 3.4.2 with
> >
> > -O3 -gnatnp -march=pentium4 -fomit-frame-pointer
> >
> > the time was reduced from about 1.8 s for the original to about 1.1 s
> > with this modification, a speedup of 38.9%. Applied to the 2.71 s
> > reported time, that would give GNAT 1.66 s, which would move it to 3rd
> > place.
> >
> > I hope no one thinks we're picking on Jim.
> >
> > --
> > Jeff Carter
> > "Your mother was a hamster and your father smelt of elderberries."
> > Monty Python & the Holy Grail
> > 06
>
> Thanks for the reminder that I should throwout/fix the programs that
> use a test to avoid doing what the benchmark description asks them to
> do :-)
And that has now been done (although it will be a little while before
the ripple reaches the Debian/AMD measurements).
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-28 17:45 ` Martin Krischik
` (2 preceding siblings ...)
2006-10-29 4:58 ` Isaac Gouy
@ 2006-10-30 18:26 ` jtg
2006-10-30 21:50 ` george
` (3 more replies)
2006-11-12 22:26 ` Shootout / pidigits [Re: ada is getting spanked :(] Gautier
4 siblings, 4 replies; 44+ messages in thread
From: jtg @ 2006-10-30 18:26 UTC (permalink / raw)
Martin Krischik wrote:
>
> And there is still one test missing for Ada.
>
Some time ago I started to implement it. However, the problem requires
usage of big integers, which are not supported by Ada.
However, gcc has very fast library (gmp), which can be used in c and c++
programs just by inserting "# include <gmp.h>" into a program file and
"-lgmp" into a compiler command-line.
Is there any standard Ada binding to the GMP library? By "standard
binding" I mean a binding included in gnat/gcc.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-30 18:26 ` jtg
@ 2006-10-30 21:50 ` george
2006-10-31 4:57 ` Jeffrey R. Carter
` (2 subsequent siblings)
3 siblings, 0 replies; 44+ messages in thread
From: george @ 2006-10-30 21:50 UTC (permalink / raw)
jtg wrote:
> Is there any standard Ada binding to the GMP library? By "standard
> binding" I mean a binding included in gnat/gcc.
You can take a look here:
https://bugs.gentoo.org/show_bug.cgi?id=132119
As you can see, this is on my list, but first I need to finish with the
transition to split gnat compilers (should be soon finally - only a few
libs left) - in Gentoo you have the ability to have multiple gnat
implementation installed side-by-side and switch them on the fly..
>From the description it seems that the link in the last posting may be
in decent shape, however I did not look at it in detail yet..
George
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-30 18:26 ` jtg
2006-10-30 21:50 ` george
@ 2006-10-31 4:57 ` Jeffrey R. Carter
2006-10-31 6:28 ` Gautier
2006-10-31 6:47 ` Martin Krischik
3 siblings, 0 replies; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-10-31 4:57 UTC (permalink / raw)
jtg wrote:
>
> Some time ago I started to implement it. However, the problem requires
> usage of big integers, which are not supported by Ada.
> However, gcc has very fast library (gmp), which can be used in c and c++
> programs just by inserting "# include <gmp.h>" into a program file and
> "-lgmp" into a compiler command-line.
> Is there any standard Ada binding to the GMP library? By "standard
> binding" I mean a binding included in gnat/gcc.
How big do they need to be? Signed or unsigned?
--
Jeff Carter
"Mr. President, we must not allow a mine-shaft gap!"
Dr. Strangelove
33
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-30 18:26 ` jtg
2006-10-30 21:50 ` george
2006-10-31 4:57 ` Jeffrey R. Carter
@ 2006-10-31 6:28 ` Gautier
2006-10-31 6:47 ` Martin Krischik
3 siblings, 0 replies; 44+ messages in thread
From: Gautier @ 2006-10-31 6:28 UTC (permalink / raw)
jtg:
> Some time ago I started to implement it. However, the problem requires
> usage of big integers, which are not supported by Ada.
Sure they are! Only on this page you have 5 flavours of them:
http://www.chez.com/bignumber/
A quick look on Google seems to give some more.
> However, gcc has very fast library (gmp), which can be used in c and c++
> programs just by inserting "# include <gmp.h>" into a program file and
> "-lgmp" into a compiler command-line.
> Is there any standard Ada binding to the GMP library? By "standard
> binding" I mean a binding included in gnat/gcc.
The AdaGMP bindings seem to be no more available, however, you can give
a try with my package which doesn't even require dynamic allocation:
http://homepage.sunrise.ch/mysunrise/gdm/gsoft.htm#mathpaqs
see the mathpaqs.zip archive, mupreint.ad* files.
There are also a test and a RSA cypher using it.
HTH
Gautier
_______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm
NB: For a direct answer, e-mail address on the Web site!
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-30 18:26 ` jtg
` (2 preceding siblings ...)
2006-10-31 6:28 ` Gautier
@ 2006-10-31 6:47 ` Martin Krischik
2006-11-02 18:21 ` Jeffrey R. Carter
3 siblings, 1 reply; 44+ messages in thread
From: Martin Krischik @ 2006-10-31 6:47 UTC (permalink / raw)
jtg schrieb:
> Martin Krischik wrote:
>
>>
>> And there is still one test missing for Ada.
>>
>
> Some time ago I started to implement it. However, the problem requires
> usage of big integers, which are not supported by Ada.
> However, gcc has very fast library (gmp), which can be used in c and c++
> programs just by inserting "# include <gmp.h>" into a program file and
> "-lgmp" into a compiler command-line.
> Is there any standard Ada binding to the GMP library? By "standard
> binding" I mean a binding included in gnat/gcc.
I too have looked into implementing the test. I found out that there are
several Big_Integer implementations - some a binding - some native.
Really one would need to implement the test with all of them to find out
which is the most effective Big_Integer implementation.
To much for a lone developer but a collaboration could do it.
Martin
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 21:33 ` Leif Holmgren
@ 2006-10-31 11:04 ` Harald Korneliussen
2006-11-01 11:28 ` jtg
0 siblings, 1 reply; 44+ messages in thread
From: Harald Korneliussen @ 2006-10-31 11:04 UTC (permalink / raw)
Leif Holmgren wrote:
> jtg wrote:
> > Leif Holmgren wrote:
> >
> >> Has anyone ever tried to measure the important programming language
> >> speed aspects? What I mean is
> >> - Time to implement a complex algo by an average programmer, including
> >> bug-fixing.
> >
> >
> > There is one natural environment for such tests: programming
> > competition. For example at topcoder (www.topcoder.com) you can see some
> > statistics (average coding time, best coding time, correct programs
> > percentage etc.) for several languages used in these competitions.
> > Unfortunately, the languages are only C++, C#, java and Visual Basic.
> >
>
> Without having looked I believe the problem is that such sites will only
> attract the really talented programmers. And a talented programmer can
> write fortran in any programming language.
>
> What's really interesting is the result from those coders that go home
> after their 8 hours in front of the terminal and dont spend five minutes
> thinking about software until they are back at work the next day.
Topcoder is a bit of a swindle, really. They have competitions to
design and implement various component, but even if you should win, the
hourly wage would be lousy. Topcoder programmers are either obsessed
about their reputation, or dirt-poor out of work eastern
europeans/asians. Sometimes both. The site is made for the sponsors,
not the participants, and it shows everywhere, not only in language
alternatives.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 23:50 ` Björn Persson
@ 2006-10-31 11:32 ` Dmitry A. Kazakov
2006-10-31 13:12 ` Georg Bauhaus
0 siblings, 1 reply; 44+ messages in thread
From: Dmitry A. Kazakov @ 2006-10-31 11:32 UTC (permalink / raw)
On Sun, 29 Oct 2006 23:50:24 GMT, Bj�rn Persson wrote:
> Georg Bauhaus wrote:
>> How could a notion of REs be both precise and precisely
>> applicable to the ways in which various PLs implement them?
>> E.g. how can you turn off Boyer-Moore string searching when
>> one implementation has it, just so that only some specified
>> internal way of pattern matching is compared?
>
> I wasn't talking of internal implementations. As I understand it,
> "regex" is a name of a family of similar notations for expressing
> patterns. If you don't write "[ABC]*" for "any number of A's, B's and
> C's in any order", then it isn't regex.
Actually RE is not a notation, it is a formal language. SNOBOL patterns
represent a different wider class of languages. For example SNOBOL can
matching balanced strings like (a(b))(c). Technically, a highly optimized
implementation of RE should beat SNOBOL.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-31 11:32 ` Dmitry A. Kazakov
@ 2006-10-31 13:12 ` Georg Bauhaus
2006-10-31 14:14 ` Dmitry A. Kazakov
0 siblings, 1 reply; 44+ messages in thread
From: Georg Bauhaus @ 2006-10-31 13:12 UTC (permalink / raw)
On Tue, 2006-10-31 at 12:32 +0100, Dmitry A. Kazakov wrote:
> Actually RE is not a notation, it is a formal language. SNOBOL patterns
> represent a different wider class of languages. For example SNOBOL can
> matching balanced strings like (a(b))(c). Technically, a highly optimized
> implementation of RE should beat SNOBOL.
Why? Boyer-Moore and similar algorithms may well be part
of any string scanning machine, no matter what languages
it can recognize. By the AS-IF rule, as long as RE semantics
are followed, I don't see a reason why optimized RE
scanning should be faster than optimized CF scanning.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-31 13:12 ` Georg Bauhaus
@ 2006-10-31 14:14 ` Dmitry A. Kazakov
0 siblings, 0 replies; 44+ messages in thread
From: Dmitry A. Kazakov @ 2006-10-31 14:14 UTC (permalink / raw)
On Tue, 31 Oct 2006 14:12:41 +0100, Georg Bauhaus wrote:
> On Tue, 2006-10-31 at 12:32 +0100, Dmitry A. Kazakov wrote:
>
>> Actually RE is not a notation, it is a formal language. SNOBOL patterns
>> represent a different wider class of languages. For example SNOBOL can
>> matching balanced strings like (a(b))(c). Technically, a highly optimized
>> implementation of RE should beat SNOBOL.
>
> Why? Boyer-Moore and similar algorithms may well be part
> of any string scanning machine, no matter what languages
> it can recognize. By the AS-IF rule, as long as RE semantics
> are followed, I don't see a reason why optimized RE
> scanning should be faster than optimized CF scanning.
Yes, if you (the compiler) *can* understand semantics.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-29 16:27 ` Björn Persson
2006-10-29 20:23 ` Georg Bauhaus
@ 2006-10-31 18:01 ` Martin Krischik
1 sibling, 0 replies; 44+ messages in thread
From: Martin Krischik @ 2006-10-31 18:01 UTC (permalink / raw)
Bjï¿œrn Persson wrote:
> The requirements clearly state that
> regular expressions should be used.
But they did not say "perl-regex", "sed-regex", etc. pp.
Martin
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-31 11:04 ` Harald Korneliussen
@ 2006-11-01 11:28 ` jtg
2006-11-01 14:31 ` Harald Korneliussen
0 siblings, 1 reply; 44+ messages in thread
From: jtg @ 2006-11-01 11:28 UTC (permalink / raw)
Harald Korneliussen wrote:
> Topcoder is a bit of a swindle, really.
It is not swindle, because it has clear and stable rules.
It is not for making money by the participants. It is for improving
skills, assessing skills and providing some kind of skills certificate.
Usually you have to pay for these services.
Participants are mostly students, but there are also programmers looking
for a better job.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-11-01 11:28 ` jtg
@ 2006-11-01 14:31 ` Harald Korneliussen
0 siblings, 0 replies; 44+ messages in thread
From: Harald Korneliussen @ 2006-11-01 14:31 UTC (permalink / raw)
Ok, then, I moderate myself somewhat. Topcoder isn't a swindle, it's a
rip-off. They get people to develop software components for them for
almost nothing, by calling it a competition. I don't think the alleged
gains to reputation and experience are valuable enough to compensate
for this - don't you get that at regular employers too, if you do a
reasonably good job?
No, there is one software competition I have way more respect for, and
that is the ICFP. No prizes, but extremely impressing displays of skill
(as well as truly original challenges). It's may be a little biased for
tasks that functional languages are suited for (despite what they say),
but notetheless.
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-10-31 6:47 ` Martin Krischik
@ 2006-11-02 18:21 ` Jeffrey R. Carter
2006-11-02 19:37 ` Gautier
2006-11-03 12:06 ` Martin Krischik
0 siblings, 2 replies; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-11-02 18:21 UTC (permalink / raw)
Martin Krischik wrote:
>
> I too have looked into implementing the test. I found out that there are
> several Big_Integer implementations - some a binding - some native.
>
> Really one would need to implement the test with all of them to find out
> which is the most effective Big_Integer implementation.
I have implemented the Pi-digits program using Jerome Delcourt's
Big_Number package
http://www.chez.com/bignumber/info.htm
2500 digits takes about 7 s on my 3.2 GHz Pentium 4 HT/WinXP machine, so
that would be about 9 s on the comparison machine, putting Ada in the
vicinity of Python.
I looked at Gautier de Montmollin's package, but there doesn't seem to
be a way to convert a big-num to an Integer.
Based on the Free Pascal entry, binding to gmp would be much faster.
--
Jeff Carter
"I soiled my armor, I was so scared."
Monty Python & the Holy Grail
71
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-11-02 18:21 ` Jeffrey R. Carter
@ 2006-11-02 19:37 ` Gautier
2006-11-03 5:11 ` Jeffrey R. Carter
2006-11-03 12:06 ` Martin Krischik
1 sibling, 1 reply; 44+ messages in thread
From: Gautier @ 2006-11-02 19:37 UTC (permalink / raw)
Jeffrey R. Carter:
> I looked at Gautier de Montmollin's package, but there doesn't seem to
> be a way to convert a big-num to an Integer.
Mmmh, you looked at multi002.zip on Jerome's page, which appears to be
outdated, and not at mathpaqs.zip, where you have:
-- Convert basic_int to multi_int
function Multi(small: Basic_int) return Multi_int;
-- Convert multi_int to basic_int (when possible, else: Cannot_fit raised)
function Basic(large: Multi_int) return Basic_int;
I'd be keen to give a try. Do you have a piece of code I could
continue with that pi test ?
Cheers, Gautier
______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm
NB: For a direct answer, e-mail address on the Web site!
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-11-02 19:37 ` Gautier
@ 2006-11-03 5:11 ` Jeffrey R. Carter
0 siblings, 0 replies; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-11-03 5:11 UTC (permalink / raw)
Gautier wrote:
>
> Mmmh, you looked at multi002.zip on Jerome's page, which appears to be
> outdated, and not at mathpaqs.zip, where you have:
>
> -- Convert basic_int to multi_int
> function Multi(small: Basic_int) return Multi_int;
>
> -- Convert multi_int to basic_int (when possible, else: Cannot_fit
> raised)
> function Basic(large: Multi_int) return Basic_int;
Yes, that's correct.
> I'd be keen to give a try. Do you have a piece of code I could
> continue with that pi test ?
I based mine on the Pascal version.
--
Jeff Carter
"I soiled my armor, I was so scared."
Monty Python & the Holy Grail
71
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-11-02 18:21 ` Jeffrey R. Carter
2006-11-02 19:37 ` Gautier
@ 2006-11-03 12:06 ` Martin Krischik
2006-11-03 19:59 ` Jeffrey R. Carter
1 sibling, 1 reply; 44+ messages in thread
From: Martin Krischik @ 2006-11-03 12:06 UTC (permalink / raw)
Jeffrey R. Carter schrieb:
> Martin Krischik wrote:
>>
>> I too have looked into implementing the test. I found out that there
>> are several Big_Integer implementations - some a binding - some native.
>>
>> Really one would need to implement the test with all of them to find
>> out which is the most effective Big_Integer implementation.
>
> I have implemented the Pi-digits program using Jerome Delcourt's
> Big_Number package
>
> http://www.chez.com/bignumber/info.htm
>
> 2500 digits takes about 7 s on my 3.2 GHz Pentium 4 HT/WinXP machine, so
> that would be about 9 s on the comparison machine, putting Ada in the
> vicinity of Python.
Would you mind adding it to the wikibook ada subversion archive
http://sourceforge.net/projects/wikibook-ada
So we will never loose it.
> I looked at Gautier de Montmollin's package, but there doesn't seem to
> be a way to convert a big-num to an Integer.
>
> Based on the Free Pascal entry, binding to gmp would be much faster.
But still faster then no entry as no entry is treated as slower then the
slowest in the overall statistic.
Martin
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: ada is getting spanked :(
2006-11-03 12:06 ` Martin Krischik
@ 2006-11-03 19:59 ` Jeffrey R. Carter
0 siblings, 0 replies; 44+ messages in thread
From: Jeffrey R. Carter @ 2006-11-03 19:59 UTC (permalink / raw)
Martin Krischik wrote:
>
> Would you mind adding it to the wikibook ada subversion archive
>
> http://sourceforge.net/projects/wikibook-ada
>
> So we will never loose it.
Loose, an adjective, is the opposite of Tight. Lose is a verb.
I don't have subversion or the time right now to get it and figure out
how to do this. I'll stick the code here so you can copy it and add it.
I compiled with
-O3 -gnatnpws -march=pentium4 -fomit-frame-pointer
-gnatws (suppress all warnings) because there's unreachable code in the
big-num packages that generates a bunch of warnings.
Here it is:
-- Shootout header should go here.
with Ada.Command_Line;
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Big_Number;
procedure Pi_Digits is
type Big_Index is mod 2 ** 16;
package Bignum is new Big_Number
(Index_Type => Big_Index, Nb_Item => 3300);
subtype Big is Bignum.Big_Signed;
use Bignum.Signed_Number;
function To_Big is new
Bignum.Generic_Conversion.Int_Number2Big_Signed
(Int_Generic => Integer);
function To_Float (Num : Big) return Long_Long_Float renames
Bignum.Conversion.Big_Signed2Long_Long_Float;
procedure Output_Pi (Num_Digits : in Integer) is
-- State : transformation matrix components
Q : Big := Bignum.Big_Signed_One;
R : Big := Bignum.Big_Signed_Zero;
S : Big := Bignum.Big_Signed_Zero;
T : Big := Bignum.Big_Signed_One;
-- Work variables
U : Big;
V : Big;
W : Big;
X_Big : Big;
K_Big : Big;
K2 : Big;
K4 : Big;
K : Natural := 0;
Digit : Integer;
Ten : constant Big := To_Big (10);
function Extract (X : Natural) return Integer is
-- null;
begin -- Extract
X_Big := To_Big (X);
U := Q * X_Big + R;
V := S * X_Big + T;
W := U / V;
return Integer (To_Float (W) );
end Extract;
function Safe (Digit : Integer) return Boolean is
-- null;
begin -- Safe
return Digit = Extract (4);
end Safe;
pragma Inline (Safe);
procedure Produce is
-- null;
begin -- Produce
V := T * To_Big (-10 * Digit);
R := Ten * R + V;
Q := Ten * Q;
end Produce;
procedure Consume is
-- null;
begin -- Consume
K := K + 1;
K_Big := To_Big (K);
K2 := To_Big (2 * K + 1);
K4 := To_Big (4 * K + 2);
U := Q * K4;
R := R * K2 + U;
V := S * K4;
T := T * K2 + V;
S := S * K_Big;
Q := Q * K_Big;
end Consume;
subtype Line_Str is String (1 .. 10);
I : Natural := 0;
C : Natural := 0;
Line : Line_Str;
begin -- Output_Pi
loop
exit when I >= Num_Digits;
loop
Digit := Extract (3);
exit when Safe (Digit);
Consume;
end loop;
Produce;
C := C + 1;
Line (C) := Character'Val (Character'Pos ('0') + Digit);
I := I + 1;
if C >= 10 then
C := 0;
Ada.Text_IO.Put (Item => Line & ASCII.HT & ':');
Ada.Integer_Text_IO.Put (Item => I, Width => 1);
Ada.Text_IO.New_Line;
end if;
end loop;
if C /= 0 then
Ada.Text_IO.Put (Item => Line (1 .. C) &
String'(C + 1 .. 10 => ' ') &
ASCII.HT & ':');
Ada.Integer_Text_IO.Put (Item => I, Width => 1);
Ada.Text_IO.New_Line;
end if;
end Output_Pi;
N: Positive := 2500;
begin -- Pi_Digits
if Ada.Command_Line.Argument_Count > 0 then
N := Integer'Value (Ada.Command_Line.Argument (1) );
end if;
Output_Pi (Num_Digits => N);
end Pi_Digits;
--
Jeff Carter
"We call your door-opening request a silly thing."
Monty Python & the Holy Grail
17
^ permalink raw reply [flat|nested] 44+ messages in thread
* Shootout / pidigits [Re: ada is getting spanked :(]
2006-10-28 17:45 ` Martin Krischik
` (3 preceding siblings ...)
2006-10-30 18:26 ` jtg
@ 2006-11-12 22:26 ` Gautier
4 siblings, 0 replies; 44+ messages in thread
From: Gautier @ 2006-11-12 22:26 UTC (permalink / raw)
There is now a pi_digits_gmp.adb submitted for the shootout, using GMP.
Took around 1 hour from the Pascal version: P2Ada, rewriting the Import
pragmata, some clean-up...
https://alioth.debian.org/tracker/?atid=411646&group_id=30402&func=browse
Gautier
Martin Krischik wrote:
> cl1 wrote:
>
>> I just got wind of this site. It would seem that ada, while not at
>> the very bottom, is one of the slowest languages in this benchmark
>> competition:
>>
>> http://shootout.alioth.debian.org
>
> Looks worse then last time I looked. Seems that some language advocates
> really optimised there implementations.
>
> And there is still one test missing for Ada.
>
> Martin
______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm
NB: For a direct answer, e-mail address on the Web site!
^ permalink raw reply [flat|nested] 44+ messages in thread
end of thread, other threads:[~2006-11-12 22:26 UTC | newest]
Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-28 16:29 ada is getting spanked :( cl1
2006-10-28 17:45 ` Martin Krischik
2006-10-28 20:02 ` Georg Bauhaus
2006-10-29 1:34 ` Georg Bauhaus
2006-10-29 2:13 ` Jeffrey R. Carter
2006-10-29 4:48 ` Isaac Gouy
2006-10-30 1:01 ` Isaac Gouy
2006-10-29 2:26 ` Jeffrey R. Carter
2006-10-29 2:30 ` Jeffrey R. Carter
2006-10-29 2:33 ` Jeffrey R. Carter
2006-10-29 17:19 ` Jeffrey R. Carter
2006-10-29 17:25 ` Jeffrey R. Carter
2006-10-29 8:54 ` Martin Krischik
2006-10-29 13:01 ` Georg Bauhaus
2006-10-30 0:46 ` Isaac Gouy
2006-10-29 16:27 ` Björn Persson
2006-10-29 20:23 ` Georg Bauhaus
2006-10-29 23:50 ` Björn Persson
2006-10-31 11:32 ` Dmitry A. Kazakov
2006-10-31 13:12 ` Georg Bauhaus
2006-10-31 14:14 ` Dmitry A. Kazakov
2006-10-31 18:01 ` Martin Krischik
2006-10-29 4:58 ` Isaac Gouy
2006-10-29 8:46 ` Martin Krischik
2006-10-30 0:17 ` Isaac Gouy
2006-10-30 18:26 ` jtg
2006-10-30 21:50 ` george
2006-10-31 4:57 ` Jeffrey R. Carter
2006-10-31 6:28 ` Gautier
2006-10-31 6:47 ` Martin Krischik
2006-11-02 18:21 ` Jeffrey R. Carter
2006-11-02 19:37 ` Gautier
2006-11-03 5:11 ` Jeffrey R. Carter
2006-11-03 12:06 ` Martin Krischik
2006-11-03 19:59 ` Jeffrey R. Carter
2006-11-12 22:26 ` Shootout / pidigits [Re: ada is getting spanked :(] Gautier
2006-10-28 22:45 ` ada is getting spanked :( Larry Kilgallen
2006-10-29 16:22 ` Leif Holmgren
2006-10-29 17:28 ` Simon Wright
2006-10-29 19:21 ` jtg
2006-10-29 21:33 ` Leif Holmgren
2006-10-31 11:04 ` Harald Korneliussen
2006-11-01 11:28 ` jtg
2006-11-01 14:31 ` Harald Korneliussen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox