#include #include #include #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) /* for solaris */ #ifdef SOLARIS #include #include struct tms tp1,tp2; static void start_timer() { times(&tp1); } static double end_timer() { times(&tp2); return((tp2.tms_utime - tp1.tms_utime)/(1.0*CLK_TCK)); } #elif (defined(LINUX)) #include struct rusage tp1,tp2; static void start_timer() { getrusage(RUSAGE_SELF,&tp1); } static double end_timer() { getrusage(RUSAGE_SELF,&tp2); return((tp2.ru_utime.tv_sec - tp1.ru_utime.tv_sec) + (tp2.ru_utime.tv_usec - tp1.ru_utime.tv_usec)*1.0e-6); } #else #include struct timeval tp1,tp2; static void start_timer() { gettimeofday(&tp1,NULL); } static double end_timer() { gettimeofday(&tp2,NULL); return((tp2.tv_sec - tp1.tv_sec) + (tp2.tv_usec - tp1.tv_usec)*1.0e-6); } #endif static FILE *f; static void dumpval(double val) { fwrite((void *)&val,sizeof(val),1,f); } static void memcpy_test(int size) { int i; int loops = 5.0e8 / size; char *p1 = (char *)malloc(size); char *p2 = (char *)malloc(size); double t; memset(p2,42,size); start_timer(); for (i=0;i