I have the same single thread problem, which is something like a simple
#include<stdlib.h>
#include<iostream>
#include<stdio.h>
#include<time.h>
//#include<ctime.h>
int main(){
clock_t start=clock();
for (int i=0;i<100 000 000; i++){
//do something here
}
double duration = (clock()-start)/(double)CLOCKS_PER_SEC;
cout<<endl<<"Total consumption time is : "<<duration<<"seconds "<<endl;
// or use
// printf("\n Total consumption time is : %lf seconds",duration);
system("pause");
return 0;
}
Occasionally when I was running them on different computer: older one with XP OS and Pentium V CPU, newer one with Win7 OS x86 and i7 CPU.
It is very strange that I found the older computer runs the same program significantly faster. Then I found it is general for other similar programs.
Why I got such result? Is it because XP OS is faster than Win7?
duration. Maybe this is related?: CLOCKS_PER_SEC not actually clocks per sec – horchler Dec 05 '13 at 16:05printf,cout, etc.) This should minimize the dependence on your OS version and truly compare the CPUs. (Though the truth is that there are some surprising things that depend on system functions...---I had a similar problem where the same, seemingly purely numerical code ran much faster on Linux than Win) – Szabolcs Dec 05 '13 at 17:56