/* ** cleanbench.c */ /******************************************* ** BYTEmark (tm) ** ** BYTE MAGAZINE'S NATIVE MODE BENCHMARKS ** ** FOR CPU/FPU ** ** ver 2.0 ** ** Rick Grehan, BYTE Magazine ** ******************************************** ** NOTE: These benchmarks do NOT check for the presence ** of an FPU. You have to find that out manually. ** ** REVISION HISTORY FOR BENCHMARKS ** 9/94 -- First beta. --RG ** 12/94 -- Bug discovered in some of the integer routines ** (IDEA, Huffman,...). Routines were not accurately counting ** the number of loops. Fixed. --RG (Thanks to Steve A.) ** 12/94 -- Added routines to calculate and display index ** values. Indexes based on DELL XPS 90 (90 MHz Pentium). ** 1/95 -- Added Mac time manager routines for more accurate ** timing on Macintosh (said to be good to 20 usecs) -- RG ** 1/95 -- Re-did all the #defines so they made more ** sense. See NMGLOBAL.H -- RG ** 3/95 -- Fixed memory leak in LU decomposition. Did not ** invalidate previous results, just made it easier to run.--RG ** 3/95 -- Added TOOLHELP.DLL timing routine to Windows timer. --RG ** 10/95 -- Added memory array & alignment; moved memory ** allocation out of LU Decomposition -- RG ** ** DISCLAIMER ** The source, executable, and documentation files that comprise ** the BYTEmark benchmarks are made available on an "as is" basis. ** This means that we at BYTE Magazine have made every reasonable ** effort to verify that the there are no errors in the source and ** executable code. We cannot, however, guarantee that the programs ** are error-free. Consequently, McGraw-HIll and BYTE Magazine make ** no claims in regard to the fitness of the source code, executable ** code, and documentation of the BYTEmark. ** Furthermore, BYTE Magazine, McGraw-Hill, and all employees ** of McGraw-Hill cannot be held responsible for any damages resulting ** from the use of this code or the results obtained from using ** this code. */ #include #include #include #include #include #include #include "nmglobal.h" #include "cleanbench.h" #include "hardware.h" /************* **** main **** *************/ int main(int argc, char *argv[]) { int i; /* Index */ time_t time_and_date; /* Self-explanatory */ struct tm *loctime; double bmean; /* Benchmark mean */ double bstdev; /* Benchmark stdev */ double lx_memindex; /* Linux memory index (mainly integer operations)*/ double lx_intindex; /* Linux integer index */ double lx_fpindex; /* Linux floating-point index */ double intindex; /* Integer index */ double fpindex; /* Floating-point index */ unsigned long bnumrun; /* # of runs */ /* ** Set global parameters to default. */ global_min_ticks=MINIMUM_TICKS; global_min_seconds=MINIMUM_SECONDS; global_allstats=0; global_custrun=0; global_align=8; write_to_file=0; lx_memindex=(double)1.0; /* set for geometric mean computations */ lx_intindex=(double)1.0; lx_fpindex=(double)1.0; intindex=(double)1.0; fpindex=(double)1.0; /* ** We presume all tests will be run unless told ** otherwise */ for(i=0;i1) for(i=1;i(double)1e-100){ /* avoid division by zero */ printf(" Relative standard deviation: %g %%\n", (double)100*bstdev/bmean); } printf(" Number of runs: %lu\n",bnumrun); show_stats(i); printf("Done with %s\n\n",ftestnames[i]); } } } /* printf("...done...\n"); */ /* ** Output the total indexes */ if(global_custrun==0) { puts("==========================ORIGINAL BYTEMARK RESULTS=========================="); printf("INTEGER INDEX : %.3f\n", pow(intindex,(double).142857)); printf("FLOATING-POINT INDEX: %.3f\n", pow(fpindex,(double).33333)); puts("Baseline (MSDOS*) : Pentium* 90, 256 KB L2-cache, Watcom* compiler 10.0"); #ifdef __linux__ puts("==============================LINUX DATA BELOW==============================="); hardware(write_to_file, global_ofile); #include "sysinfoc.c" printf("MEMORY INDEX : %.3f\n", pow(lx_memindex,(double).3333333333)); printf("INTEGER INDEX : %.3f\n", pow(lx_intindex,(double).25)); printf("FLOATING-POINT INDEX: %.3f\n", pow(lx_fpindex,(double).3333333333)); puts("Baseline (LINUX) : AMD K6/233*, 512 KB L2-cache, gcc 2.7.2.3, libc-5.4.38"); #endif puts("* Trademarks are property of their respective holder."); } return 0; } /************** ** parse_arg ** *************** ** Given a pointer to a string, we assume that's an argument. ** Parse that argument and act accordingly. ** Return 0 if ok, else return -1. */ static int parse_arg(char *argptr) { int i; /* Index */ FILE *cfile; /* Command file identifier */ /* ** First character has got to be a hyphen. */ if(*argptr++!='-') return(-1); /* ** Convert the rest of the argument to upper case ** so there's little chance of confusion. */ for(i=0;i]\n",progname); printf(" -v = verbose\n"); printf(" -c = input parameters thru command file \n"); exit(0); } /***************** ** read_comfile ** ****************** ** Read the command file. Set global parameters as ** specified. This routine assumes that the command file ** is already open. */ static void read_comfile(FILE *cfile) { char inbuf[40]; char *eptr; /* Offset to "=" sign */ int i; /* Index */ /* ** Sit in a big loop, reading a line from the file at each ** pass. Terminate on EOF. */ while(fgets(inbuf,39,cfile)!=(char *)NULL) { /* Overwrite the CR character */ if(strlen(inbuf)>0) inbuf[strlen(inbuf)-1]='\0'; /* ** Parse up to the "=" sign. If we don't find an ** "=", then flag an error. */ if((eptr=strchr(inbuf,(int)'='))==(char *)NULL) { printf("**COMMAND FILE ERROR at LINE:\n %s\n", inbuf); goto skipswitch; /* A GOTO!!!! */ } /* ** Insert a null where the "=" was, then convert ** the substring to uppercase. That will enable ** us to perform the match. */ *eptr++='\0'; strtoupper((char *)&inbuf[0]); i=MAXPARAM; do { if(strcmp(inbuf,paramnames[i])==0) break; } while(--i>=0); if(i<0) { printf("**COMMAND FILE ERROR -- UNKNOWN PARAM: %s", inbuf); goto skipswitch; } /* ** Advance eptr to the next field...which should be ** the value assigned to the parameter. */ switch(i) { case PF_GMTICKS: /* GLOBALMINTICKS */ global_min_ticks=(unsigned long)atol(eptr); break; case PF_MINSECONDS: /* MINSECONDS */ global_min_seconds=(unsigned long)atol(eptr); set_request_secs(); break; case PF_ALLSTATS: /* ALLSTATS */ global_allstats=getflag(eptr); break; case PF_OUTFILE: /* OUTFILE */ strcpy(global_ofile_name,eptr); global_ofile=fopen(global_ofile_name,"a"); /* ** Open the output file. */ if(global_ofile==(FILE *)NULL) { printf("**Error opening output file: %s\n", global_ofile_name); exit(1); } write_to_file=-1; break; case PF_CUSTOMRUN: /* CUSTOMRUN */ global_custrun=getflag(eptr); for(i=0;i30)) { puts("Internal error: calc_confidence called with an illegal number of scores"); return(-1); } /* ** First calculate mean. */ *smean=(double)0.0; for(i=0;i