There's several mantras that I tend to follow (not dogmatically of course, since that's the sign of a weak mind).
1/ Measure, don't guess.
Don't presume to think that you know how computers or compilers or even cars work. They've all long since moved beyond the simplicity of the Apple II or my old 1966 Holden HR station wagon (I miss being able to fix my own car without buying some maintenance computer from Toyota).
If you really want to know how fast something is, you have to measure it. Do you think Ferrari put stuff in their Formula 1 cars just on the off-chance it might make them go faster? No (well, I hope not), they design and test and measure and throw away quite a lot of ideas that don't make the grade.
Profile your options then choose the best - that's one of the differences between software engineering and cowboy coding. Document your choices, perhaps even leaving the slower options in your code (unused) if anything ever changes in the future.
2/ Get it working first, then get it working fast.
Don't optimize something until you're almost certain that it's functionally stable. Otherwise the optimization is wasted when you have to re-engineer it.
3/ Target your optimizations.
There's absolutely no point in getting a 100% performance boost in a piece of code that runs once a month and takes 7 seconds.
Find out where your program is spending most of its time and target that. If you can find a piece of code where you're spending half of the time and you can increase it's speed by 10%, that's equivalent to getting a 500% boost for a piece of code where you're only spending 1% of the time.
4/ The user is all that matters. Period.
This is an extension of point 3. Why are you writing software? You might be writing it for pure pleasure but most business applications (and plenty of non-business ones) have users.
And they don't care if your application delivers email twice as fast or how long a background DB task takes.
But, if you can speed up the interface so that what used to take 3 seconds now takes one second, they'll elevate you to godhood.
Some of the best improvements I've made have been pseudo-improvements - the task as a whole takes the same amount of time but it looks quicker to the user.
This is where splash screens came from, it made it look like the application was doing something sooner. Initialization wasn't any faster, the user still had to wait for it to finish, but the user saw the splash screen and said: "Ah, the application has started".