c use Makefile test
created a Makefile:
build: register_test.c
gcc -c register_test.c
link: register_test.o
gcc -o register_test register_test.o
run: register_test
./register_test
clean:
rm -f *.o *.exe *.executable
ou:
cd output/
make -C Makefile
create a .c file:
regitster_test.c (測試用register 有沒有比較省時
#include <stdio.h>
#include <sys/time.h>
int main( int argc, char* argv[])
{
struct timeval start, end;
gettimeofday( &start, NULL);
double timeuse;
register double sum;
register int j,k;
for(j=0;j<1000000000;j++)
for(k=0;k<10;k++)
sum=sum+1.0;
gettimeofday( &end, NULL);
timeuse = 1000000*(end.tv_sec - start.tv_sec)+ end.tv_sec-start.tv_usec;
timeuse /= 1000000;
printf(" implement time : %f \n", timeuse);
return 0;
}
build: register_test.c
gcc -c register_test.c
link: register_test.o
gcc -o register_test register_test.o
run: register_test
./register_test
clean:
rm -f *.o *.exe *.executable
ou:
cd output/
make -C Makefile
create a .c file:
regitster_test.c (測試用register 有沒有比較省時
#include <stdio.h>
#include <sys/time.h>
int main( int argc, char* argv[])
{
struct timeval start, end;
gettimeofday( &start, NULL);
double timeuse;
register double sum;
register int j,k;
for(j=0;j<1000000000;j++)
for(k=0;k<10;k++)
sum=sum+1.0;
gettimeofday( &end, NULL);
timeuse = 1000000*(end.tv_sec - start.tv_sec)+ end.tv_sec-start.tv_usec;
timeuse /= 1000000;
printf(" implement time : %f \n", timeuse);
return 0;
}
留言
張貼留言