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=3.1 required=5.0 tests=BAYES_05,PDS_OTHER_BAD_TLD, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bcdac28207102750 X-Google-Attributes: gid103376,public From: "Clifford J. Nelson" Subject: Re: Ada95 speed Date: 1999/05/20 Message-ID: <3743D5BB.37152F94@gte.net> X-Deja-AN: 479991027 Distribution: world Content-Transfer-Encoding: 7bit References: <374182F2.B10AD449@Maths.UniNe.CH> <3741aa37.3892645@news.pacbell.net> <3741B203.4890880B@Maths.UniNe.CH> <7ht4ss$4mu$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353" X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Complaints-To: abuse@gte.net X-Trace: /wmQqyiuGKyFYJs43AupcEznW2qIBhMqE5S01FmQ6Uhfl+e21CiCaVpRDcpBmLvxtAnldgKO/nvy!KaKg/lRYNDrMb9q36ss/p4XxwgL+RQcPuNlmGW09dlANM6qCn9QBIb6O MIME-Version: 1.0 NNTP-Posting-Date: Thu, 20 May 1999 08:34:40 GMT Reply-To: cnelson9@gte.net Newsgroups: comp.lang.ada Date: 1999-05-20T00:00:00+00:00 List-Id: 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;