I often have to write code that I would like to optimize for performance, and I often have several solutions to a particular problem.
Is there a simple way to determine the number of CPU cycles a particular statement/function would take? I'm not talking about complex code that access the file system, Windows APIs or the network, I'm talking about comparing half a dozen lines of C++ code to determine which code would be more efficient.
The classic example would be comparing ++i with i++. The former is faster, but without knowing that, how would I be able to determine this myself?
I'd rather not install costly performance tools (e.g. Intel's tools), but find a simple way to get to the bottom. Is there a way to see the Assembler code that is generated by C++ code - without debugging?
Any other suggestions and/or approaches are of course welcome.