Sunday, August 11, 2013

Optimize your program

I just find out a heuristic to optimize the program, in term of improving the performance. Your program often requires a check of condition A whether it is True or False. Normally this check is cost.
The rule to optimize this check is to try to find some invariant in your program.  There are some constraints in your program. Combine with these constraints with the invariant you found, we can find a simple, cheaper to check a condition A.

PS: I will try to find a simple example to illustrate this method.