How to improve your code
The following advice is based on this video tutorial by Nick Wright: http://www.sdsc.edu/us/training/elearning/login/index.php
You are the expert
First of all, you are the export of your own code. You know best what is possible, what algorithms that are used, and how the program in general works.
Do I need to optimize my code?
If your program is running only once or twice, then probably not. For instance if your program is going to run for only two days, why would you spend an extra day optimizing it?
Where should I start?
First of all, you should never make guesses about how your program is performing. You should always measure it, and base your intuition on these measurements, not on guesses.
Secondly, there is something called the 80/20 rule. That is, for a general program, you will have that approximately 80% of the time is used on running approximately 20% of the code. That gives you that there is only approximately 20% of your code that you really need to optimize.
When should I stop?
At some point, you will have a program that runs acceptably fast. The goal of optimization isn't necessarily to get an optimal runtime, but about getting an acceptable runtime, and an efficient use of resources. For instance, if your program uses less then 20% of the total walltime on communication, that is considered acceptable in many situations.

