Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The mistery of speed optimisation : (x^2-y^2)
#1
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 !
hink Global, Make Symp' All ! ®
[Image: Banner.gif]
Reply
#2
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.
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply
#3
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
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
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
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply
#5
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
....
Antoni
Reply
#6
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...
hink Global, Make Symp' All ! ®
[Image: Banner.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)