I wanted to stress out the processor on a new computer at work. I figured a good way to do it would be to open a thread for each processor with the function:
void soStressful() {
int j = 0;
for (int i = 0; i < 10000; ++i) {
j += i;
}
}
But for some reason the compiler takes this code away. (Because the program runs instantly regardless of the complexity of the calculation or the size of i) and we also log very little cpu usage.
How can I stop the compiler for compiling out this code?