Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make my code fast [closed]

Please can anyone one point me to a good tutorial that helps me to make my code fast and light. I'm interested to know which Method is faster and when to use a method instead of other...
And how to evaluate if a code is good or bad?
My programming language is C#.

Hi all,
Thanks for your replies, they are very helpful.
I'm editing my question to be more specific specially that optimization is unlimited.
I want to know what is the best method in each condition.
For example using StringBuilder is better than string if i am appending lines to a string... I only need this simple things.

like image 508
Gaby Avatar asked Feb 23 '10 07:02

Gaby


1 Answers

Be aware of sub optimization.

Even though one specific function is faster than another replacing this isn't necessarily gonna make any difference in the runtime of your application. You need to understand which parts of your code that actually is a potential problem, and focus on optimizing these parts. Be aware of the O notation of your functions, and how often they are called. To identify parts that needs optimization a profiler can be of good help.

This question has some interesting points on why you shouldn't optimize until there is actually a need to do so.

like image 55
stiank81 Avatar answered Sep 26 '22 18:09

stiank81