C#include <time.h>#include <unistd.h>#include <stdio.h> double processCpuTime(){ struct timespec tp; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp); return tp.tv_sec + tp.tv_nsec * 1.0e-9;} int main(){ int i; int ii; const int maxii=0xfffffff; double id; const int maxid=maxii; double time=processCpuTime(); for(ii=0;ii<maxii;ii++); printf("int sum time: %g\n",processCpuTime()-time); time = processCpuTime(); for(id=0;id<maxid;id++); printf("double sum time: %g\n",processCpuTime()-time); printf("=================================================\n",processCpuTime()-time); time = processCpuTime(); for(i=0;i<10000;i++) for(ii=maxii;ii>1;ii/=2); printf("int div2 time: %g\n",processCpuTime()-time); time = processCpuTime(); for(i=0;i<10000;i++) for(ii=maxii;ii>1;ii>>=2); printf("int shift div2 time: %g\n",processCpuTime()-time); time = processCpuTime(); for(i=0;i<10000;i++) for(id=maxid;id>1;id/=2); printf("double div2 time: %g\n",processCpuTime()-time); printf("=================================================\n",processCpuTime()-time); time = processCpuTime(); for(i=0;i<10000;i++) for(ii=maxii;ii>1;ii/=3); printf("int div3 time: %g\n",processCpuTime()-time); time = processCpuTime(); for(i=0;i<10000;i++) for(id=maxid;id>1;id/=3); printf("double div3 time: %g\n",processCpuTime()-time); printf("=================================================\n",processCpuTime()-time); time = processCpuTime(); for(i=0;i<10000;i++) for(ii=maxii;ii>1;ii/=7); printf("int div7 time: %g\n",processCpuTime()-time); time = processCpuTime(); for(i=0;i<10000;i++) for(id=maxid;id>1;id/=7); printf("double div7 time: %g\n",processCpuTime()-time); }