Last. In other words, first write your code in the clearest way, which is likely to entail standard mathematical operations. Let the compiler take care of the rest.
Java, since it runs on a virtual machine, has other interesting built-in optimization functions: for example, as your program starts, the VM can see which code branches are executed most often and make these branches more efficient.
Once you write your program, use the profiling tool to measure which specific methods are slow. Once you know this, you will know which code needs to be optimized. For example, you may find that reading the configuration from a file is the slowest thing you do, and you can look for ways to make it faster. My guess is that you are unlikely to find any performance advantage using things like bitwise operators rather than regular arithmetic.
Good luck
source share