I want the program to spend some time running but 'for ( ; ; )' is not suitable because I do not want it to run forever. I want something that I can kind of control how long it runs. That is, I want something like
and then I can adjust the maximum loop index (1000, 10000, 100000, ..) depending on the actual run. But apparently the compiler optimizes away the loop though I use the -O0 flag with gcc.Code:for (i; i<1000; i++) x = x + i;
What is an effective and efficient way to do this?