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.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: Florian Weimer Subject: Re: Ada95 speed Date: 1999/05/18 Message-ID: #1/1 X-Deja-AN: 478829970 References: <3740C535.7C6200A8@gte.net> Mail-Copies-To: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@cygnus.stuttgart.netsurf.de X-Trace: deneb.cygnus.stuttgart.netsurf.de 927005900 1739 192.168.0.1 (18 May 1999 05:38:20 GMT) Organization: Penguin on board User-Agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) XEmacs/21.1 (20 Minutes to Nikko) Mime-Version: 1.0 NNTP-Posting-Date: 18 May 1999 05:38:20 GMT Newsgroups: comp.lang.ada Date: 1999-05-18T05:38:20+00:00 List-Id: "Clifford J. Nelson" writes: > 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. You obviously used a different algorithm. > exit when (abs( Z)) > 2.0; This statement is executed approximately 6 million times. Calculating the absolute value of a complex number involves taking a square root. This is a very expensive operation and dominates the running time by far. I'd suggest to square both sides of the inequation and use: exit when (Z.Re * Z.Re + Z.Im * Z.Im) > 4.0; I suppose your C code does exactly that because C hasn't got built-in complex types, so this optimization is more obvious.