I'm creating this code to time how long it takes a processor to do this operation for a school project. The problem was I couldn't get my loop working without printing every a result, if I didn't print the result of every a when multiplied by i, the processor would skip the loop. After solving this problem I tought than I am trying to benchmark my CPU and if I print every result it might affect on the performance or the time it takes to solve the operations. I've trying adding an if in the loop and only printing a when i=999999 but it doesn't work. Anybody can help?
#include <iostream>
#include <ctime>
using namespace std;
int main () {
int start_s=clock();
int i;
for(i=0;i<1000000;i++){
int a = i*434243;
if(i = 999999){
cout<<a;
}
}
int stop_s=clock();
cout << "time: "<< (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000;
cout<<"ms";
system ("pause");
return 0;
}