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

Username:   Password: 
 RegisterRegister   
 Turing Coding Practises! Keep your code running Quickly!
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
copthesaint




PostPosted: Mon Jan 30, 2012 11:07 am   Post subject: Turing Coding Practises! Keep your code running Quickly!

Hello everyone, Ive been trying to optimise my program that I've been making and while doing this and testing what runs quicker I thought I would share it with compsci.
If anyone else has things that they know by testing are slower create a thread and post the link here, please Smile.
here are a few things you can do to keep your code running at your preferred fps.

Don't use functions. Use Procedures instead. adding that extra parameter can save you a bit of headache. Click >here< to learn why.

Don't use View.Update. Use View.UpdateArea instead. Spend two seconds to specify the dimensions of the screen and save in speed. Check out why >here<

Use predefines types if possible! Types can slow you down. Click >here< for more info
Sponsor
Sponsor
Sponsor
sponsor
2goto1




PostPosted: Mon Jan 30, 2012 11:44 am   Post subject: RE:Turing Coding Practises! Keep your code running Quickly!

Some good observations and a nice, simple way to benchmark performance in your examples. Realistically though Turing is not the best choice to develop a program where performance is a concern, unless this is an academic exercise. You could develop a program in any other number of other languages and realize a significant performance improvement above Turing's without having to resort to learning about that language's performance-specific enhancements.
mirhagk




PostPosted: Mon Jan 30, 2012 1:03 pm   Post subject: RE:Turing Coding Practises! Keep your code running Quickly!

@copthesaint, actually nearly all of your suggestions are poor ideas. The performance hit next to nothing for functions and predefined types, and they are much cleaner, simpler ways to do things.

If you only care about speed I'd suggest learning MASM, but good coding practices are more important than a 20% performance increase.

(btw you can directly access memory in Turing, which might be faster than using variables, but the question is, why would you throw out the cleaner way of doing it for a slight performance increase).

Also you should look into big-o-expressions and algorithm timing. The point of it is, constant increases in time are important, only increases that increase as input increases. The algorithm you choose is MUCH more important than a small 20% increase in speed by avoiding functions.
DemonWasp




PostPosted: Mon Jan 30, 2012 1:56 pm   Post subject: Re: RE:Turing Coding Practises! Keep your code running Quickly!

mirhagk @ Mon Jan 30, 2012 1:03 pm wrote:
Also you should look into big-o-expressions and algorithm timing. The point of it is, constant increases in time are important, only increases that increase as input increases. The algorithm you choose is MUCH more important than a small 20% increase in speed by avoiding functions.


Agreed. I recently wrote a naive implementation of QT clustering (for work) that took 8 hours to run on ~2k items. I sped it up a few times and now it takes about 3 seconds to process 4k items. Both implementations were written in the same language (Java) and I didn't deliberately write the first edition to be slow in any way.
mirhagk




PostPosted: Mon Jan 30, 2012 2:06 pm   Post subject: RE:Turing Coding Practises! Keep your code running Quickly!

Exactly. Even turing could probably be faster than another language if you design the right algorithm.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: