In his program to change one line - added "Number": Dim v (4,6), x, y as Number
Productivity remained at the same level.
What should also change the code?
You should also declare the local variables as Numbers:
Code:
Sub Globals 'Fractal Dim v(4,6) As Number,x As Number,y As Number x=0 y=0 v()=Array((0,0,0,0.16,0,0),(0.85,0.04,-0.04,0.85,0,1.6),(0.2,-0.26,0.23,0.22,0,1.6),(-0.15,0.28,0.26,0.24,0,0.44)) End Sub
Sub App_Start Fractal.Show t=Now Fractal.DrawString("Fractal",12,10,10,10,30,cGreen) Dim i As Number, r As Number, x1 As Number, y1 As Number, c As Number For i=1To10000'quality: 10000-70000 r=Rnd(0,100)/100 If r>=0AND r<0.01Then c=0 If r>=0.01AND r<0.8Then c=1 If r>=0.8AND r<0.9Then c=2 If r>=0.9AND r<=1Then c=3 x1=(v(c,0)*x)+(v(c,1)*y)+v(c,4) y1=(v(c,2)*x)+(v(c,3)*y)+v(c,5) x=x1 y=y1 Fractal.Line(x*23+100,235-y*23,x*23+100+1,235-y*23+1,cGreen) If i Mod100 = 0ThenDoEvents Next Msgbox((Now-t) / cTicksPerSecond) End Sub
The main overhead in this program is caused by refreshing the screen every iteration.
Run the code I posted and you will see that it is running very fast because of this line:
Code:
If i Mod100 = 0ThenDoEvents
I see an improvement of 50% between the typed version and the untyped version.
I made performance comparisons with my, desktop only, 'Dynamic simulations' program with lots of calculation.
The calculation time of a simulation with B4PPC version 6.851, optimzed compiled, is 3 times faster than the 6.80 version.
But the same program in VB is still 5 times faster than the 6.851 version ?
I would have expected better than three times improvement. On pure computation Erel and I have seen over 100 times improvement for entirely computation bound code. How about posting the new code so I can have a look at it?
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Attached is the whole project, not a small one, as it is now.
There are lots of calculations but with internal loops and If Then tests.
The time is measured from the click on the calulation button and the end of the calculation and is displayed in Calculation time.
There still seem to be variables and structs/arrays not declared as Number so I don't think that you have got the full speed up possible. Note that although declaring arrays as Double in previous versions speeded the calculations up declaring them Number or Double makes a bigger difference in this new version for technical reasons to do with what a typed array actually is now compared to what it was before.
Normally I don't like multi-statement lines but while I've been playing with a pre-beta version I found it useful to to implement typed initialised globals like this to keep the declaration and initialisation together and make the code easier to read.
Dim Something As Number : Something = 1.2345 ' whatever Something is
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
I have updated all variable declarations, also the variables for array indexes.
Now the speed increase is a little bit higher than 6.
The VB6 program is now 'only' 2 times faster.
Really a big speed improvement.
A certain number of the array variables were already declared as Double in the 6.80 version.
I removed the Double declarations in the 'old' version, result the 6,851 version is 10 times faster.