Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Never Use View.Update
Index -> Programming, Turing -> Turing Tutorials
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
copthesaint




PostPosted: Mon Feb 09, 2009 8:43 am   Post subject: Never Use View.Update

While Programing I stummbled across a Program That uses View.Update And View.UpdateArea.
I decided I will change The program around and I had learnt from this.
Useing
code:
View.UpdateArea (0,0,Maxx,Maxy)

Can Increase your Program Speed By up to 25% (larger the program smaller the increase)
So instead of
code:
View.Update

Use
code:
View.UpdateArea (0,0,Maxx,Maxy)


Here Is my program that proves this.
You will get Different Results Everytime. (smaller the Maple leaf, Faster the animation)
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Mon Feb 09, 2009 9:29 am   Post subject: RE:Never Use View.Update

Though your code is a bit off, your conclusion seems valid. Where you're computing how much faster, you should have:
code:
NumResult := realstr ( num3 / num1 * 100 - 100, 0 )

Alternately, you could substitute num2 for num3 there.

It makes perfect sense to me that updating only a portion of the screen should be faster, but I'm confused - why would updating the entire screen using UpdateArea() be faster than just Update() ?
copthesaint




PostPosted: Mon Feb 09, 2009 10:21 am   Post subject: RE:Never Use View.Update

Maybe Because View.Update Usese a procedure that is more line then View.UpdateArea. Beace you are Supplieing The X,Y,X2,Y2 positions maybe. All I know That is It's faster And Can increase your programs speed, and the Program clearly proves that it is faster.
SNIPERDUDE




PostPosted: Mon Feb 09, 2009 2:31 pm   Post subject: RE:Never Use View.Update

Wow, this is actually an incredible find. Many thanks
Tony




PostPosted: Mon Feb 09, 2009 3:57 pm   Post subject: Re: Never Use View.Update

A problem with this test is that Time measured as a resolution of a second, out of 5 seconds, could introduce an error of up to 1 second in size (if a test starts at the end of a second), which would randomly give a 1/5 = 20% difference. I found the results to vary greatly (which should have been a clue that there's a problem), and I've even gotten a negative result.

A better idea is to use Time.Elapsed, timing to 5000 milliseconds. The results were much more consistent, hovering at about 8 +/-1 %; using DemonWasp's NumResult.

Which makes sense, because you are updating a smaller area.

The View.UpdateArea (0,0,Maxx,Maxy) is at 0 +/- 1 %; often in the negatives.



Picture 4.png
 Description:
 Filesize:  52.55 KB
 Viewed:  458 Time(s)

Picture 4.png


Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
DemonWasp




PostPosted: Mon Feb 09, 2009 4:47 pm   Post subject: RE:Never Use View.Update

Ah, cleverly done, Tony. I was getting slightly concerned that perhaps I'd descended into some sort of chaotic nonsense world where updating the whole screen was slower than updating the whole screen.
saltpro15




PostPosted: Mon Feb 09, 2009 5:39 pm   Post subject: RE:Never Use View.Update

well I'll be damned... that is the best post I have ever read, thanks a lot man, helps SO much in my game, went from 8 fps to 13 fps
Clayton




PostPosted: Mon Feb 09, 2009 7:58 pm   Post subject: RE:Never Use View.Update

I would have thought this would have been fairly obvious. Double buffering a fraction of the screen is faster than double buffering the whole screen? Less work means more speed (Note: This does not mean that Update() has more LoC (Lines of Code) than UpdateArea()). If someone had read my tutorial in the Turing Walkthrough, one would (should, anyways) know this.
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Mon Feb 09, 2009 8:12 pm   Post subject: RE:Never Use View.Update

I think the point is that View.UpdateArea (0, 0, maxx, maxy), which does buffer the whole screen, is faster than View.Update, which also updates the whole screen.
Clayton




PostPosted: Mon Feb 09, 2009 8:14 pm   Post subject: RE:Never Use View.Update

insectoid wrote:
I think the point is that View.UpdateArea (0, 0, maxx, maxy) ... is faster than View.Update ...
Tony wrote:
The View.UpdateArea (0,0,Maxx,Maxy) is at 0 +/- 1 %; often in the negatives.


Not by much. If at all.
mirhagk




PostPosted: Tue Dec 15, 2009 12:28 pm   Post subject: RE:Never Use View.Update

To be honest I'm a little confused by all of this, so changing from View.Update to View.UpdateArea(0,0,maxx,maxy) doesn't really help??

Also would it be better to use View.UpdateArea right after I draw every object?? (as long as I don't have to many objects that overlap)
DemonWasp




PostPosted: Tue Dec 15, 2009 1:13 pm   Post subject: RE:Never Use View.Update

No and no, respectively.
mirhagk




PostPosted: Tue Dec 15, 2009 2:03 pm   Post subject: RE:Never Use View.Update

why wouldn't it be?? it would update only the parts of the screen that have changed
DemonWasp




PostPosted: Tue Dec 15, 2009 2:39 pm   Post subject: RE:Never Use View.Update

Yes, but assuming you're updating any sizeable portion of the screen, the overhead of updating many areas of the screen independently of each other would likely dwarf the overhead of updating areas of the screen that may not need updating. Imagine the extreme case: 1 call to View.Update() to update the entire screen, or maxx*maxy updates to update individual pixels. Which would be faster? Obviously the first. There are situations where you could get a targeted View.UpdateArea to perform better, but not if you update any portion of the screen with regularity (such as moving the view around a map, for example).
mirhagk




PostPosted: Tue Dec 15, 2009 3:00 pm   Post subject: RE:Never Use View.Update

yeah of course if I have a lot of objects that are changing on screen, but I meant if I have for instance a mario game (where the background picture remains the same)

All i'd be updating is the tiles and mario so would it run faster than View.Update
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: