MCPcopy Create free account
hub / github.com/AdvancedCompiler/AdvancedCompiler / main

Function main

code/Chapter2/2-3.c:7–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5int a[N],b[N],c[N];
6int i;
7int main(){
8 for(i= 0; i <N; i++){
9 a[i]=i+ 1;
10 b[i]=i+2;
11 c[i]=i+3;
12}
13 struct timeval start,end;
14 gettimeofday(&start,NULL);
15for(i=0;i<N-4;i+=4){
16 c[i]=c[i]+a[i]*b[i];
17 c[i+1]=c[i+1]+a[i+1]*b[i+1];
18 c[i+2]=c[i+2]+a[i+2]*b[i+2];
19 c[i+3]=c[i+3]+a[i+3]*b[i+3];
20 }
21 for(;i<N;i++)
22 c[i]=c[i]+a[i]*b[i];
23 gettimeofday(&end,NULL);
24 double timeuse=(end.tv_sec-start.tv_sec)+(end.tv_usec-start.tv_usec)/1000000.0;
25 printf("time=%f\n",timeuse);
26 return 0;
27}

Callers

nothing calls this directly

Calls 1

gettimeofdayFunction · 0.85

Tested by

no test coverage detected