Optimization is the process of improving an existing program to make it work more efficiently or/and using less resources.
103
votes
30answers
7k views
Is micro-optimisation important when coding?
I recently asked a question on Stack Overflow to find out why isset() was faster than strlen() in php. This raised questions around the importance of readable code and whether performance improvements ...
65
votes
19answers
4k views
Is it ok to replace optimized code with readable code?
Sometimes you run into a situation where you have to extend/improve some existing code. You see that the old code is very lean, but it's also difficult to extend, and takes time to read.
Is it a good ...
60
votes
37answers
5k views
What is the best retort to “premature optimization is the root of all evil” [closed]
Often I hear the sentiment ...
"Why worry about performance, write slow code, get your product to market ... don't worry about performance. You can sort that out later"
The culmination of this ...
53
votes
16answers
2k views
Why should I care about micro performance and efficency?
Many questions and answers on the C/C++ pages, specifically or indirectly discuss micro performance issues (such is the overhead of an indirect vs direct vs inline function), or using an O(N2) vs ...
43
votes
9answers
5k views
Clean readable code vs fast hard to read code. When to cross the line?
When I write code I always try to make my code as clean and readable as possible.
Every now and then there comes a time when you need to cross the line and go from nice clean code to slightly uglier ...
41
votes
13answers
4k views
Is premature optimization really the root of all evil?
A colleague of mine today committed a class called ThreadLocalFormat, which basically moved instances of Java Format classes into a thread local, since they are not thread safe and "relatively ...
35
votes
9answers
1k views
When is optimization not premature and therefore not evil?
"Premature optimization is root of all evil" is something almost all of us have heard/read. What I am curious what kind of optimization not premature, i.e. at every stage of software development (high ...
33
votes
13answers
9k views
How have languages influenced CPU design?
We are often told that the hardware doesn't care what language a program is written in as it only sees the compiled binary code, however this is not the whole truth. For example, consider the humble ...
29
votes
20answers
2k views
Should you sacrifice code readability with how efficient code is?
Should you sacrifice code readability with how efficient code is?
e.g. 3 lines of code into 1 line.
I read in Code Craft by Pete Goodliffe that readability is key.
Your thoughts?
20
votes
18answers
692 views
What do you optimize for?
Generally speaking, what type of optimizations do you typically slant yourself towards when designing software?
Are you the type that prefers to optimize your design for
Development time (i.e., ...
20
votes
6answers
811 views
Does the advent of the SSD have any implication for database optimization?
Today I was browsing through a book on SQL Server optimization and it seemed that a certain amount of the ideas were based on a linear model of storage. As SSDs have a completely different storage ...
19
votes
10answers
566 views
Is it always wrong to optimize before profiling?
I see the mantra of "profiling before optimization" repeated again and again here, on SO, and elsewhere. Although I certainly use profiling tools, I'm only occasionally surprised by the results. It ...
19
votes
3answers
3k views
How fast can Go go?
Go is one of the few languages that are supposed to run 'close to the metal', i. e. it's compiled, statically typed and executes code natively, without a VM. This should give it a speed advantage over ...
15
votes
4answers
699 views
Can applications affect power consumption in a substantial way?
Is there anything that can be done for a single general purpose application to affect the power consumption of the device it is running on?
I am not familiar with how optimizations to individual ...
13
votes
6answers
1k views
It takes me hours to completely understand solutions to 1000-pt problems on TopCoder. Should I get discouraged? [closed]
Sometimes this applies to the 500-pt ones too. I sometimes start feeling I will never improve enough to code them with ease like the others. Should I just quit? If not, why? It is extremely annoying, ...