comp.lang.ada
 help / color / mirror / Atom feed
From: "Clifford J. Nelson" <cnelson9@gte.net>
Subject: Re: Ada95 speed
Date: 1999/05/20
Date: 1999-05-20T00:00:00+00:00	[thread overview]
Message-ID: <3743D5BB.37152F94@gte.net> (raw)
In-Reply-To: 7ht4ss$4mu$1@nnrp1.deja.com

Here is the program again with all the crazy Mac operating system stuff.
The graphics are one hundred times to slow as far as I'm concerned, and
the other computations are about ten times slower than I expected. The
"computer revolution" has been smashed by performance problems and you
will have to "jump through hoops" and "thread needles" to get the
performance implied by the advertised clock speeds of new computers and
"compiled" languages.

Sorry, but, I just had to get that off my chest. The emperor has no
cloths.

   Cliff Nelson

CodeBuilder command:

macmake -O2 mandel

with
  Events,        --
  Fonts,         --InitFonts
  OSUtils,       --{SysEnvirons, GetDateTime}
  QuickDraw,     --{SetCPixel}
  QuickDrawText, --{DrawString}
  SegLoad,       --{ExitToShell}
  Types,         --{Rect}
  Windows;       --{InitWindows, NewCWindow}
with Ada.Numerics.Complex_Types;
use Ada.Numerics.Complex_Types;
use type Quickdraw.GrafPtr;

procedure Mandel is
  windRect  : aliased Types.Rect;
  seconds   : aliased Types.UInt32;
  -- Initialize everything for the program, make sure we can run.
  procedure Initialize is
    mainPtr  : Quickdraw.WindowPtr;
    error    : Types.OSErr;
    theWorld : aliased OSUtils.SysEnvRec;
  begin
    -- check for color Quickdraw? On a PowerPC!?
    error := OSUtils.SysEnvirons(1, theWorld'Access);
    if not theWorld.hasColorQD then
      OSUtils.SysBeep(50);
      SegLoad.ExitToShell;
    end if;

    -- Initialize all the needed managers.
    Quickdraw.InitGraf(Quickdraw.qd.thePort'Access);
    Fonts.InitFonts;
    Windows.InitWindows;
    QuickDraw.InitCursor;

    -- Open a new color window somewhat smaller than the screen
    windRect := QuickDraw.qd.screenBits.bounds;
    QuickDraw.InsetRect (windRect'access, 0, 0);
    MainPtr := Windows.NewCWindow(Types.nil, windRect'access, "Mandel
Land",
      true, Windows.documentProc, Windows.FrontMost, false, 0);
    QuickDraw.SetPort(MainPtr);            -- set window to current
grafport
    windRect := MainPtr.portRect;          -- use the window's portRect
  end Initialize;

  procedure Display is
    ballColor : aliased QuickDraw.RGBColor;
    X, Y : Float;
    Secs : Long_Integer;
    C, Z : Complex;
    NumberofColors : constant := 97;
    MaxColor : constant := (2 ** 16) - 1;
    Itadjuster : constant := ((2 ** 33) - 1) / NumberofColors;
    Vertical_Size : constant Short_Integer := windRect.bottom -
windRect.top;
    Horizontal_Size : constant Short_Integer := windRect.Right -
windRect.left;
    Ver_Size : constant Float := Float(Vertical_Size );
    Hor_Size : constant Float := Float(Horizontal_Size );
    Mag : constant Float := 2.01 / Hor_Size;
    StartY : constant Float := -Mag * Ver_Size;
    StartX : constant Float := -Mag * Hor_Size;
    Step : constant Float :=  2.0 * Mag ;

  begin
   OSUtils.GetDateTime (seconds'Access);
   Secs := Long_Integer(seconds);
   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..NumberofColors loop
          if (Z.Re * Z.Re + Z.Im * Z.Im) > 4.0  then
           ballColor.red   := Types.UInt16(Itadjuster * I);
           ballColor.green := Types.UInt16(Itadjuster * (I ** 3));
           ballColor.blue  := Types.UInt16(Itadjuster * (I ** 2));
           Quickdraw.SetCPixel(Short_Integer(X_Pos),
Short_Integer(Y_Pos),
           ballColor'Access);
           exit;
          end if;
         Z := Z * Z + C; -- Complex arithmetic
        end loop;
    X := X + Step;
    end loop;
   Y := Y + Step;
   end loop;
   OSUtils.GetDateTime (seconds'Access);
   Secs := Long_Integer(seconds) - Secs;
   Quickdraw.MoveTo(windRect.left + 10,
      windRect.top + 40);
   ballColor.red   := Types.UInt16(MaxColor);
   ballColor.green := Types.UInt16(MaxColor);
   ballColor.blue  := Types.UInt16(MaxColor);
   Quickdraw.RGBForeColor(ballColor'Access);
   Quickdrawtext.DrawString("It took " & Long_Integer'Image(Secs) & "
seconds.");
   Quickdraw.MoveTo(windRect.left + 10,
      windRect.bottom - 40);
   Quickdrawtext.DrawString("Click mouse botton to quit.");
  end Display;

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






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

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <374182F2.B10AD449@Maths.UniNe.CH>
1999-05-18  0:00 ` Ada95 speed Tom Moran
1999-05-18  0:00   ` Gautier
1999-05-19  0:00     ` Robert Dewar
1999-05-20  0:00       ` Clifford J. Nelson [this message]
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             ` 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-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-03  0:00                       ` Ada95 speed (wandering off topic slightly) Dale Stanbrough
1999-06-03  0:00                         ` Larry Kilgallen
1999-06-04  0:00                           ` Aidan Skinner
1999-06-02  0:00                     ` Ada95 speed John B. Matthews, M.D.
1999-06-02  0:00                       ` Clifford J. Nelson
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
1999-06-07  0:00 Robert I. Eachus
1999-06-07  0:00 ` tmoran
  -- strict thread matches above, loose matches on Subject: below --
1999-06-06  0:00 tmoran
1999-06-06  0:00 ` Robert Dewar
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       ` Brian Rogoff
1999-06-06  0:00       ` David C. Hoos, Sr.
1999-06-07  0:00         ` Robert Dewar
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-05  0:00 tmoran
1999-06-05  0:00 ` Al Christians
1999-06-05  0:00   ` David C. Hoos, Sr.
1999-05-18  0:00 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 ` Tucker Taft
1999-05-18  0:00   ` Clifford J. Nelson
1999-05-18  0:00 ` Larry Kilgallen
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
replies disabled

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