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=1.7 required=5.0 tests=BAYES_00,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/06/01 Message-ID: <3753AA13.3F144877@gte.net> X-Deja-AN: 484387214 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> <3743D5BB.37152F94@gte.net> <310519991456230875%hopperj@macconnect.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: /wLjgSkIfBb5jNV7rlkCpmC5edadTAxo2a52LGr5yLSbSeBQmyxazwmTgWXRfk+A+wDNPD1J4ot2!myqkD5ns7B+u1Fe5woERGvRJudT15hBBKf/81pOFA7Kt5PppeRBF0j/4 MIME-Version: 1.0 NNTP-Posting-Date: Tue, 01 Jun 1999 08:45:06 GMT Reply-To: cnelson9@gte.net Newsgroups: comp.lang.ada Date: 1999-06-01T00:00:00+00:00 List-Id: "James E. Hopper" wrote: > In article <3743D5BB.37152F94@gte.net>, Clifford J. Nelson > wrote: > > > 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 > > > > Cliff, > > When we did the codebuilder port i played with this program, and > optimized it just a bit. at one point i had it running at least and > order of magnitude faster than you have here. I could have done much > more for instance the 5 fold increase someone gave you with the > compuation of the square root was something i never tried so i guess > that would make my original optimized version about 50 times faster > than your current (i am including the graphics in my comparisions) The > code to do this optimizing totally obsured the basic algorithm. we > decided as i recall to put stupid dumb code in as we were trying to > give code that beginners to mac programming could learn from rather > than the fastest cleverist fractal algorithms and code around. > This code is not the algorithm that comes with the fractal demo program of CodeBuilder 1.1 which incidentally doesn't work at all (error 84). The Mandelbrot demo that comes with CodeBuilder is based on the "Manhattan distance" instead of the straight line Euclidean distance. None of the mac-specific demo programs work except sillyballs and hello. > > your comment that new machines are not faster than old because you have > to do clever tricks to make them work is way off the mark. unless you > went through it you have NO idea what gyrations we went through to make > code run fast on those older machines. My head aches when i think what > i went through getting fast code to run on the old 8 bit processors ;-) > If anything i have found programmers today are much lazier about > algorithms because they can get away with it more than they used to. > your whole premise rests on the aburd comparison of comparing this > simple algorith with an unknowns algorithm from years ago. unless you > can present the source code for your comparison point there is no > validity in your comparison! > > Jim I will include the corrected program in full below. I say the graphics should work fifty times faster and the color numbers should to be computed much faster. I challenge you to make it run that fast without "jumping through hoops" and "threading needles". And I assert that slow execution times of programs like this are deliberate sabotage of the so called "computer revolution". Cliff Nelson pragma suppress(all_checks); with Events, -- Fonts, --InitFonts OSUtils, --{SysEnvirons, GetDateTime} QuickDraw, --{SetCPixel} QuickDrawText, --{DrawString} SegLoad, --{ExitToShell} Types, --{Rect} Windows; --{InitWindows, NewCWindow} with Ada.Numerics.Long_Long_Complex_Types; use Ada.Numerics.Long_Long_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; pichan : QuickDraw.PicHandle; X, Y : long_long_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 long_long_float := long_long_float(Vertical_Size ); Hor_Size : constant long_long_float := long_long_float(Horizontal_Size ); Mag : constant long_long_float := 2.01 / Hor_Size; StartY : constant long_long_float := Mag * Ver_Size; StartX : constant long_long_float := -Mag * Hor_Size; Step : constant long_long_float := 2.0 * Mag ; begin OSUtils.GetDateTime (seconds'Access); Secs := Long_Integer(seconds); Y := StartY; for Y_Pos in windRect.top..windrect.bottom 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.Index2Color(Itadjuster * I,ballColor'Access); -- Quickdraw.SetCPixel(X_Pos, Y_Pos,ballColor'Access); Quickdraw.MoveTo(X_Pos,Y_Pos); Quickdraw.RGBForeColor(ballColor'Access); Quickdraw.Line(0,0); 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(0); ballColor.blue := Types.UInt16(0); 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 button to quit."); end Display; begin -- Main body of program Mandel Initialize; Display; -- draw the fractal! loop exit when Events.Button; end loop; end Mandel;