#include #include #include #include #include #include /* BenchMark.C Written by Heiner Hückstädt Gellertstraße 12 D-5090 Leverkusen 1 Public Domain Compile with Manx V3.6 cc -s Benchmark.c ln Benchmark.o -lm -lc */ float sinus,cosinus; struct Library *MathTransBase; struct Library *FPU,*OLD; float SPAtan(); float SPSin(); float SPCos(); float SPTan(); float SPSincos(); float SPSinh(); float SPCosh(); float SPTanh(); float SPExp(); float SPLog(); float SPPow(); float SPSqrt(); ULONG SPTieee(); float SPFieee(); float SPAsin(); float SPAcos(); float SPLog10(); #define DUMMY 2.0 #define MAXLOOPS 25000 BPTR fh; long time1[3]; long time2[3]; char mess[100]; long ieee; #define TIMESTART DateStamp(&time1[0]) #define TIMEEND DateStamp(&time2[0]) #define SHOWTIME Time(&time1[0],&time2[0]) #define WAITKEY Print("\nAny key to continue (ESC to quit)\n");\ Read(fh,mess,1L);\ if(mess[0] == 0x1b) goto quit_and_die long strlen(); float fputime,oldtime,fpu_all,old_all; void Print(text) register char *text; { Write(fh,text,strlen(text)); } float Time(v1,v2) long *v1; long *v2; { float time; long sek; long dummy; dummy = v2[1]-v1[1]; if (dummy == 0) sek = v2[2]-v1[2]; else sek = (dummy*3000)-v1[2]+v2[2]; time = ((float)sek)/50.0; sprintf(mess,"%d Loops in %.2f seconds\n",MAXLOOPS,time); Write(fh,mess,strlen(mess)); return(time); } void Performance() { float factor; factor = oldtime/fputime; if(factor < 1.0) { sprintf(mess,"OH BOY.. This function performs %.2f times slower\n",fputime/oldtime); Write(fh,mess,strlen(mess)); } else { sprintf(mess,"GOODIE GOODIE.. This function performs %.2f times faster\n",factor); Write(fh,mess,strlen(mess)); } if(fabs(1.0-factor) < 0.05) { sprintf(mess,"HMMM.. Seems that there is quite no difference\n"); Write(fh,mess,strlen(mess)); } } main() { register int i; fpu_all = old_all = 0.0; if((fh = Open("RAW:100/30/500/130/FPU-Mathtrans Benchmark © HH 1990",MODE_NEWFILE))) { FPU = (struct Library *)OpenLibrary("mathtrans.library",0L); OLD = (struct Library *)OpenLibrary("old-trans.library",0L); /* The old-trans.library is a renamed copy of the original mathtrans.library used only for comparision. */ if(FPU && OLD) { Print("Atan (2.0) ..\n"); MathTransBase = FPU; TIMESTART; for(i=0;i FFP %.2f => 1.0\n",old_all/fpu_all,1.0); Write(fh,mess,strlen(mess)); Print("\nPress Return to quit..\n"); Read(fh,mess,1L); quit_and_die: MathTransBase = FPU; CloseLibrary(MathTransBase); CloseLibrary(OLD); } else { Print("Error\n"); sprintf(mess,"Mathtrans Base $%lx\nOld-Trans Base $%lx\n",FPU,OLD); Write(fh,mess,strlen(mess)); Read(fh,mess,1L); } Close(fh); } }