Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Beta Versions
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Beta Versions This forum is the place to discuss issues regarding Basic4ppc beta versions.

Performance

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-25-2010, 09:01 PM
SeregaKr's Avatar
Knows the basics
 
Join Date: Feb 2008
Posts: 72
Awards Showcase
Beta Tester Beta Tester 
Total Awards: 2
Default Performance

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?
Attached Files
File Type: sbp Fractal.sbp (973 Bytes, 9 views)
File Type: zip Fractal.zip (12.8 KB, 4 views)
File Type: zip Fractal680.zip (12.7 KB, 5 views)
Reply With Quote
  #2 (permalink)  
Old 02-25-2010, 09:21 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by SeregaKr View Post
What should also change the code?
Dim v(4,6) As Number, x As Number, y As Number

You only see the performance increase when optimised compiled.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #3 (permalink)  
Old 02-26-2010, 05:27 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You should also declare the local variables as Numbers:
Code:
Sub Globals 'Fractal
    Dim v(4,6As  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=1 To 10000 'quality: 10000-70000
    r=Rnd(0,100)/100
    
If r>=0 AND r<0.01 Then c=0
    
If r>=0.01 AND r<0.8 Then c=1
    
If r>=0.8 AND r<0.9 Then c=2
    
If r>=0.9 AND r<=1 Then 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 Mod 100 = 0 Then DoEvents
    
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 Mod 100 = 0 Then DoEvents
I see an improvement of 50% between the typed version and the untyped version.
__________________
Basic4android documentation
Reply With Quote
  #4 (permalink)  
Old 02-26-2010, 05:57 AM
SeregaKr's Avatar
Knows the basics
 
Join Date: Feb 2008
Posts: 72
Awards Showcase
Beta Tester Beta Tester 
Total Awards: 2
Default

Thanks!
Reply With Quote
  #5 (permalink)  
Old 02-26-2010, 02:07 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,826
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

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 ?

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #6 (permalink)  
Old 02-26-2010, 02:12 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

VB or VB .Net?
__________________
Basic4android documentation
Reply With Quote
  #7 (permalink)  
Old 02-26-2010, 02:15 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

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.
Reply With Quote
  #8 (permalink)  
Old 02-26-2010, 03:24 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,826
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

The program is in VB6.

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.

I will have a look at all the variable declarations and set all numbers to Number, after the answer here: http://www.basic4ppc.com/forum/beta-...html#post32390

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #9 (permalink)  
Old 02-26-2010, 03:53 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

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.
Reply With Quote
  #10 (permalink)  
Old 02-26-2010, 05:46 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,826
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

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.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
MathRecompiler performance enhancer agraham Additional Libraries 12 10-18-2009 07:00 PM
Navigation Performance Saj Questions (Windows Mobile) 15 07-18-2009 12:08 PM
Performance vs Memory RandomCoder Questions (Windows Mobile) 4 02-10-2008 05:03 PM
Performance on Bitmap? Roadrunner Questions (Windows Mobile) 9 12-09-2007 03:19 PM


All times are GMT. The time now is 08:55 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0