Search code examples
c++cassemblyprocessor

Number of cycles taken for C++ or ANSI C?


Is there anywhere on the web where i can get an idea of what the various programming language syntax take in terms of processor (Core i7 and Core 2) cycles? At university i learnt the ARM assembly language and we could map the number of cycles taken to do a subtraction operator etc. I just wondered if its possible to do this with a higher level language on the Core i7 or Core 2?


Solution

  • No. That's completely dependent on the compiler you use, and what optimization settings you use, etc.

    You can use your favorite compiler and settings to generate assembly code, and from the assembly code you can make these kinds of predictions.

    However, remember that on modern architectures things like memory latency and register renaming have large effects on speed, and these effects are not obvious even from inspection of the assembly code.