2

I am a student in the Hebrew University and I am trying to measure the time of calling an empty function without optimization using c++. I understand that unrolling loop may help me get an accurate result but my problem is that is the compiler might convert the function to inline function and I want to prevent it from happening. I know that I can "hint" the compiler not do so by using volatile key word but that it may ignore this request.

thanks for the help.

Eliav
  • 29
  • 5
  • Have you consulted some techniques like inlining: http://stackoverflow.com/questions/1474030/how-can-i-tell-gcc-not-to-inline-a-function + -O0 compiler flag? – hmatar Mar 15 '17 at 12:35
  • Put the function in a separate translation unit (compile it separately). – Galik Mar 15 '17 at 12:37
  • Analyze the assembly code to see if the function call is still there. – klutt Mar 15 '17 at 12:44
  • This may depend on the compiler you use: AFAIK, MSVC++ does not consider any `inline` in Debug mode. (Otherwise, step in/step out and local variables probably wouldn't work.) (About g++ or other compilers I don't know.) – Scheff's Cat Mar 15 '17 at 14:04

0 Answers0