I am surprised that no one has mentioned this, but if you want to know the cost of individual instructions, see them here or here .
The cost of individual instructions depends on the processor, but both AMD and Intel (and any other CPU manufacturer) document this.
The problem is that costing instructions is not easy. You have many indicators that should be considered: there is latency, whether it is pipelined (in whole or in part), how large the instruction is (affects the cache of instructions), and so on. Thus, this information is really useful if you write one function that is really sensitive to performance, in which you either write the assembly yourself or carefully read the ASM created by the compiler to find and eliminate the inefficiency. And if you know well how the CPU works.
But before you get to this point, you must use a profiler like everyone else. This will help you narrow down the time spent and what needs to be optimized.
source share