Qbasicnews.com

Full Version: The mistery of speed optimisation : (x^2-y^2)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
SCM has identified a drastic speed improvement in my Mandelbrot programs - The same rule can apply to other cases...

I had written x#^2 - y#^2 in the main loop. SCM changed that to :
x#*x# - y#*y#. Speed is increased more than twice !

So I made a small benchmark, to compare three writings for the same numeric result, with and without Ffix:

Without Ffix:
x!^2 - y!^2 : Speed index 100
x!*x! - y!*y!: Speed index 224
(x!+y!)*(x!-y!): Speed index 224

x#^2 - y#^2 : Speed index 100
x#*x# - y#*y#: Speed index 228
(x#+y#)*(x#-y#): Speed index 224

With Ffix:
x!^2 - y!^2 : Speed index 224
x!*x! - y!*y!: Speed index 1345
(x!+y!)*(x!-y!): Speed index 1345

x#^2 - y#^2 : Speed index 224
x#*x# - y#*y#: Speed index 1345
(x#+y#)*(x#-y#): Speed index 1345

Needless to say I have adapted all my progs... My old Screen 12 Mandelbrot Explorer draws the first pic (300x300) in 5 seconds now, instead of 27 seconds last year ! And the SVGA version I issued last month is, at least, confortable...

Sattamassagana, SCM !
It was years ago, on my speccy when I wrote a mandelbrot program. I remember doing that exact same thing. It took bloody ages to draw a set tho. Litterally hours if I wanted to use lots of itterations.
Yup, I drawed simple patterns such as sierpinski gasket on the Speccy and it took ages. Y'know, 3.5Mhz were nice for the time, but ... Big Grin
Often a case of: I'll leave this to run while I make dinner watch a program etc. then come back to it in 2hrs time and think "fu.ck! I typed the wrong co-ords" Smile
Jark: You could also get rid of the SQR in the mandelbrot loop. After all the result of
Code:
IF SQR(X#*X#+Y#*Y#)<2 THEN
....
is the same as the result of
Code:
IF (X#*X#+Y#*Y#)<4 THEN
....
I got rid of the useless SQR's this morning... The problem with me is that I never take time to re-read what I do : since I prog what I think, instead of thinking about what I will prog, I leave these kind of "mégots" (I don't know the english term for that : it's the rest of a cigarette you just smoked) everywhere.

Antoni, I have an issue with the "point" routines. Will write a new topic...