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).

Should I use Java's String.format() if performance is important?

We have to build Strings all the time for log output and so on. Over the JDK versions we have …

java string performance string-formatting micro-optimization
fastest way to negate a number

I was thinking this morning here, what would be the fastest way to reverse a number of positive to negative …

c++ visual-c++ x86 micro-optimization visual-c++-2012
Floating point division vs floating point multiplication

Is there any (non-microoptimization) performance gain by coding float f1 = 200f / 2 in comparision to float f2 = 200f * 0.5 A professor of …

c++ floating-point micro-optimization
Which is better option to use for dividing an integer number by 2?

Which of the following techniques is the best option for dividing an integer by 2 and why? Technique 1: x = x >&…

c++ c optimization division micro-optimization
Divide by 10 using bit shifts?

Is it possible to divide an unsigned integer by 10 by using pure bit shifts, addition, subtraction and maybe multiply? Using …

math bit micro-optimization low-level integer-division
What is the best way to set a register to zero in x86 assembly: xor, mov or and?

All the following instructions do the same thing: set %eax to zero. Which way is optimal (requiring fewest machine cycles)? …

performance assembly optimization x86 micro-optimization
what is faster: in_array or isset?

This question is merely for me as I always like to write optimized code that can run also on cheap …

php performance micro-optimization
When, if ever, is loop unrolling still useful?

I've been trying to optimize some extremely performance-critical code (a quick sort algorithm that's being called millions and millions of …

performance language-agnostic optimization micro-optimization
Cost of exception handlers in Python

In another question, the accepted answer suggested replacing a (very cheap) if statement in Python code with a try/except …

python performance exception micro-optimization
Extract fractional part of double *efficiently* in C

I'm looking to take an IEEE double and remove any integer part of it in the most efficient manner possible. …

c floating-point double micro-optimization bit-manipulation