|
Code that you don't write consumes zero clock cycles. Learn your language well, so that you can use data structures and builtin functions as they are intended, and you can expect them to be pre-optimized for you. Learn in principle what is optimal, and write in that fashion. Know the documentation, and follow best practices that the docs recommend - when the compiler/language gets updated, you'll get free optimizations. Use semantic names, none of this i, j, x, y stuff (unless you're writing totally abstract math) and don't use nebulous names like "helper," when you can be more precise.
Better names help you think more precisely about your code and what you want it to do, so you can avoid unnecessary transformations, materializations, and calculations. When you've finished the program (all the unittests and acceptance tests pass), then profile. Focus on the bottlenecks. In this way, you'll get your optimal Pareto performing code. |