comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Ada95 speed
Date: 1999/05/18
Date: 1999-05-18T00:00:00+00:00	[thread overview]
Message-ID: <FBwp62.9Er.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 3740C535.7C6200A8@gte.net

Clifford J. Nelson (cnelson9@gte.net) wrote:

: Ten years ago a Mandelbrot set computation and display on a 1200x700
: screen with eight bit color took six seconds in C on a MacIIfx.

: The following computations (leaving out all the with statements that you
: need for the Mac) take ten seconds on an iMac 266 MHertz Mac OS 8.5.1
: with the CodeBuilder Ada95 GNU from Tenon. I think it should run ten
: times faster.

: Is Ada95 slow in order to be safe?

There is nothing in this code that would require any
constraint checks.  You could put a "pragma Suppress(all_checks);"
at the top of your source file to verify this.

: Is GNU Ada95 slower than most Adas?

Not particularly.

: Is the iMac slow? Mac OS 8.5.1 slow?  CodeBuilder?

The iMac is certainly much master than the MacIIfx in general,
at least for pure computation.

Probably the time is dominated by the drawing of the pixels.
The only mildly complicated numeric operation in the code below is
the call on "abs" for a complex number.  That involves 2 multiplies
and a square-root.

It would be useful to see where the time is going.  Chances are that
the generated code is running much faster, and the time is all spent
in the graphics routines drawing pixels.

: Why does it take so long?

My bet is on the graphic output routines.  The code generated 
by the Ada compiler is probably taking an immeasurably small amount 
of time.  Try changing the program so that it only does the computation.
Then add back in the graphics output.  Measure the difference in
execution time...

: Program follows--------

: with Ada.Numerics.Complex_Types;
: use Ada.Numerics.Complex_Types;

: procedure Mandel is

: -- Initialize procedure goes here for windRect.bottom and windRect.top

: procedure Display(Mag : in Float) is
:     It : Integer;
:     X, Y : Float;
:     C, Z : Complex;
:     Num_Iters : constant := 64;
:     Vertical_Maximum : constant Short_Integer := windRect.bottom;
:     Horizontal_Maximum : constant Short_Integer := windRect.Right;
:     Ver_Size : constant Float := Float(Vertical_Maximum + 1);
:     Hor_Size : constant Float := Float(Horizontal_Maximum + 1);
:     StartY : constant Float := -Mag * Ver_Size;
:     StartX : constant Float := -Mag * Hor_Size;
:     Step : constant Float :=  2.0 * Mag ;

:   begin
:    Y := StartY;
:    for Y_Pos in windRect.top..windrect.bottom - 1 loop
:       X := StartX;
:       for X_Pos in windRect.left..windRect.right loop
:         Z := (X, Y); -- Complex value; standard Ada 95!
:         C := Z;
:         for I in 0..Num_Iters loop
:           It := I;
:           exit when (abs( Z)) > 2.0;
:           Z := Z * Z + C; -- Complex arithmetic
:         end loop;
:     -- draw pixel here in color depending on variable It.
:     X := X + Step;
:     end loop;
:    Y := Y + Step;
:    end loop;
:   end Display;

: begin -- Main body of program Mandel
:   Initialize;
:    Display(0.0025); -- draw the fractal!
:   loop
:     exit when Events.Button;
:   end loop;
: end Mandel;


--
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




  parent reply	other threads:[~1999-05-18  0:00 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-18  0:00 Ada95 speed Clifford J. Nelson
1999-05-17  0:00 ` David Starner
1999-05-18  0:00   ` Clifford J. Nelson
1999-05-18  0:00 ` Florian Weimer
1999-05-18  0:00 ` Larry Kilgallen
1999-05-18  0:00 ` Tucker Taft [this message]
1999-05-18  0:00   ` Clifford J. Nelson
1999-05-20  0:00 ` Tom Moran
1999-05-21  0:00   ` Clifford J. Nelson
1999-05-21  0:00     ` Tom Moran
1999-05-21  0:00       ` Clifford J. Nelson
1999-05-21  0:00         ` Tom Moran
     [not found] <374182F2.B10AD449@Maths.UniNe.CH>
1999-05-18  0:00 ` Tom Moran
1999-05-18  0:00   ` Gautier
1999-05-19  0:00     ` Robert Dewar
1999-05-20  0:00       ` Clifford J. Nelson
1999-05-20  0:00         ` Tucker Taft
1999-05-20  0:00           ` Tom Moran
1999-05-20  0:00             ` Tom Moran
1999-05-21  0:00               ` Tom Moran
1999-05-31  0:00         ` James E. Hopper
1999-06-01  0:00           ` Clifford J. Nelson
1999-06-01  0:00             ` James E. Hopper
1999-06-02  0:00               ` Clifford J. Nelson
1999-06-04  0:00                 ` Clifford J. Nelson
1999-06-02  0:00             ` James E. Hopper
1999-06-02  0:00               ` Clifford J. Nelson
1999-06-02  0:00                 ` James E. Hopper
1999-06-02  0:00                   ` Clifford J. Nelson
1999-06-02  0:00                     ` Gautier
1999-06-02  0:00                       ` John B. Matthews, M.D.
1999-06-02  0:00                     ` John B. Matthews, M.D.
1999-06-02  0:00                       ` Clifford J. Nelson
1999-06-02  0:00             ` Robert Dewar
1999-06-04  0:00               ` Clifford J. Nelson
1999-06-04  0:00                 ` David C. Hoos, Sr.
1999-06-04  0:00                 ` Ole-Hjalmar Kristensen
1999-06-01  0:00           ` Clifford J. Nelson
1999-06-01  0:00             ` James E. Hopper
1999-06-02  0:00             ` Robert Dewar
1999-06-04  0:00               ` Clifford J. Nelson
1999-06-05  0:00                 ` Robert Dewar
1999-06-03  0:00           ` Robert I. Eachus
1999-05-31  0:00       ` Gautier
1999-05-19  0:00   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1999-06-05  0:00 tmoran
1999-06-05  0:00 ` Al Christians
1999-06-05  0:00   ` David C. Hoos, Sr.
1999-06-05  0:00 tmoran
1999-06-05  0:00 ` Robert Dewar
1999-06-05  0:00   ` Ehud Lamm
1999-06-05  0:00     ` William Starner
1999-06-05  0:00       ` Ehud Lamm
1999-06-05  0:00     ` Clifford J. Nelson
1999-06-06  0:00     ` David Botton
1999-06-06  0:00       ` Ehud Lamm
1999-06-07  0:00         ` Robert Dewar
1999-06-07  0:00           ` Ehud Lamm
1999-06-06  0:00 tmoran
1999-06-06  0:00 ` David C. Hoos, Sr.
1999-06-06  0:00   ` tmoran
1999-06-07  0:00     ` Robert Dewar
1999-06-06  0:00       ` David C. Hoos, Sr.
1999-06-07  0:00         ` Robert Dewar
1999-06-06  0:00       ` Brian Rogoff
1999-06-06  0:00 tmoran
1999-06-06  0:00 ` Robert Dewar
1999-06-07  0:00 Robert I. Eachus
1999-06-07  0:00 ` tmoran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox