Top "Micro-optimization" questions

Micro-optimization is the process of meticulous tuning of small sections of code in order to address a perceived deficiency in some aspect of its operation (excessive memory usage, poor performance, etc).

What is faster: many ifs, or else if?

I'm iterating through an array and sorting it by values into days of the week. In order to do it …

php micro-optimization
What does `rep ret` mean?

I was testing some code on Visual Studio 2008 and noticed security_cookie. I can understand the point of it, but …

assembly x86 micro-optimization branch-prediction
' ... != null' or 'null != ....' best performance?

I wrote two methods to check there performance public class Test1 { private String value; public void notNull(){ if( value != null) { //…

java performance micro-optimization
What is the fastest way to find if a number is even or odd?

What is the fastest way to find if a number is even or odd?

c micro-optimization
Java: if-return-if-return vs if-return-elseif-return

Asked an unrelated question where I had code like this: public boolean equals(Object obj) { if (this == obj) return true; …

java if-statement micro-optimization
Fastest way to strip all non-printable characters from a Java String

What is the fastest way to strip all non-printable characters from a String in Java? So far I've tried and …

java string performance optimization micro-optimization
Cycles/cost for L1 Cache hit vs. Register on x86?

I remember assuming that an L1 cache hit is 1 cycle (i.e. identical to register access time) in my architecture …

performance x86 cpu-architecture cpu-cache micro-optimization
Is it possible to tell the branch predictor how likely it is to follow the branch?

Just to make it clear, I'm not going for any sort of portability here, so any solutions that will tie …

c gcc x86 compiler-optimization micro-optimization
array_push() vs. $array[] = .... Which is fastest?

I need to add values received from MySQL into an array (PHP). Here is what I've got: $players = array(); while ($…

php mysql micro-optimization
Why does n++ execute faster than n=n+1?

In C language, Why does n++ execute faster than n=n+1? (int n=...; n++;) (int n=...; n=n+1;) Our instructor …

c micro-optimization optimization performance