From 13434a06d5f7d34be5a78f4d8ab2db1a8b1d50e5 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Wed, 12 Nov 2008 04:01:51 +0000 Subject: Remove output_string function git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@10 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- nbench0.c | 503 +++++++++++++------------------------------------------------- 1 file changed, 101 insertions(+), 402 deletions(-) (limited to 'nbench0.c') diff --git a/nbench0.c b/nbench0.c index ede6c23..8d0bf15 100644 --- a/nbench0.c +++ b/nbench0.c @@ -58,12 +58,7 @@ /************* **** main **** *************/ -#ifdef MAC -void main(void) -#else -int main(int argc, char *argv[]) -#endif -{ +int main(int argc, char *argv[]) { int i; /* Index */ time_t time_and_date; /* Self-explanatory */ struct tm *loctime; @@ -74,37 +69,7 @@ double lx_intindex; /* Linux integer index */ double lx_fpindex; /* Linux floating-point index */ double intindex; /* Integer index */ double fpindex; /* Floating-point index */ -ulong bnumrun; /* # of runs */ - -#ifdef MAC - MaxApplZone(); -#endif - -#ifdef MACTIMEMGR -/* Set up high res timer */ -MacHSTdelay=600*1000*1000; /* Delay is 10 minutes */ - -memset((char *)&myTMTask,0,sizeof(TMTask)); - -/* Prime and remove the task, calculating overhead */ -PrimeTime((QElemPtr)&myTMTask,-MacHSTdelay); -RmvTime((QElemPtr)&myTMTask); -MacHSTohead=MacHSTdelay+myTMTask.tmCount; -#endif - -#ifdef WIN31TIMER -/* Set up the size of the timer info structure */ -win31tinfo.dwSize=(DWORD)sizeof(TIMERINFO); -/* Load library */ -if((hThlp=LoadLibrary("TOOLHELP.DLL"))<32) -{ printf("Error loading TOOLHELP\n"); - exit(0); -} -if(!(lpfn=GetProcAddress(hThlp,"TimerCount"))) -{ printf("TOOLHELP error\n"); - exit(0); -} -#endif +unsigned long bnumrun; /* # of runs */ /* ** Set global parameters to default. @@ -160,13 +125,6 @@ global_nnetstruct.adjust=0; global_lustruct.adjust=0; -/* -** For Macintosh -- read the command line. -*/ -#ifdef MAC -UCommandLine(); -#endif - /* ** Handle any command-line arguments. */ @@ -179,85 +137,59 @@ if(argc>1) /* ** Output header */ -#ifdef LINUX -output_string("\nBYTEmark* Native Mode Benchmark ver. 2 (10/95)\n"); -output_string("Index-split by Andrew D. Balsa (11/97)\n"); -output_string("Linux/Unix* port by Uwe F. Mayer (12/96,11/97)\n"); -#else -output_string("BBBBBB YYY Y TTTTTTT EEEEEEE\n"); -output_string("BBB B YYY Y TTT EEE\n"); -output_string("BBB B YYY Y TTT EEE\n"); -output_string("BBBBBB YYY Y TTT EEEEEEE\n"); -output_string("BBB B YYY TTT EEE\n"); -output_string("BBB B YYY TTT EEE\n"); -output_string("BBBBBB YYY TTT EEEEEEE\n\n"); -output_string("\nBYTEmark (tm) Native Mode Benchmark ver. 2 (10/95)\n"); -#endif +puts("\nBYTEmark* Native Mode Benchmark ver. 2 (10/95)"); +puts("Index-split by Andrew D. Balsa (11/97)"); +puts("Linux/Unix* port by Uwe F. Mayer (12/96,11/97)"); /* ** See if the user wants all stats. Output heading info ** if so. */ if(global_allstats) { - output_string("\n"); - output_string("============================== ALL STATISTICS ===============================\n"); + puts("\n============================== ALL STATISTICS ==============================="); time(&time_and_date); loctime=localtime(&time_and_date); - sprintf(buffer,"**Date and time of benchmark run: %s",asctime(loctime)); - output_string(buffer); - sprintf(buffer,"**Sizeof: char:%u short:%u int:%u long:%u uint8_t:%u uint16_t:%u uint32_t:%u int32:%u\n", - (unsigned int)sizeof(char), - (unsigned int)sizeof(short), - (unsigned int)sizeof(int), - (unsigned int)sizeof(long), - (unsigned int)sizeof(uint8_t), - (unsigned int)sizeof(uint16_t), - (unsigned int)sizeof(uint32_t), - (unsigned int)sizeof(int32_t)); - output_string(buffer); -#ifdef LINUX + printf("**Date and time of benchmark run: %s", asctime(loctime)); + printf("**Sizeof: char:%u short:%u int:%u long:%u uint8_t:%u uint16_t:%u uint32_t:%u int32:%u\n", + sizeof(char), + sizeof(short), + sizeof(int), + sizeof(long), + sizeof(uint8_t), + sizeof(uint16_t), + sizeof(uint32_t), + sizeof(int32_t)); +#ifdef LINUX /* FIXME: do this a better way */ #include "sysinfo.c" #else - sprintf(buffer,"**%s\n",sysname); - output_string(buffer); - sprintf(buffer,"**%s\n",compilername); - output_string(buffer); - sprintf(buffer,"**%s\n",compilerversion); - output_string(buffer); + printf("**%s\n",sysname); + printf("**%s\n",compilername); + printf("**%s\n",compilerversion); #endif - output_string("=============================================================================\n"); + puts("============================================================================="); } /* ** Execute the tests. */ -#ifdef LINUX -output_string("\nTEST : Iterations/sec. : Old Index : New Index\n"); -output_string(" : : Pentium 90* : AMD K6/233*\n"); -output_string("--------------------:------------------:-------------:------------\n"); -#endif +puts("\nTEST : Iterations/sec. : Old Index : New Index"); +puts(" : : Pentium 90* : AMD K6/233*"); +puts("--------------------:------------------:-------------:------------"); for(i=0;i(double)1e-100){ /* avoid division by zero */ - sprintf(buffer," Relative standard deviation: %g %%\n", + printf(" Relative standard deviation: %g %%\n", (double)100*bstdev/bmean); - output_string(buffer); } - sprintf(buffer," Number of runs: %lu\n",bnumrun); - output_string(buffer); + printf(" Number of runs: %lu\n",bnumrun); show_stats(i); - sprintf(buffer,"Done with %s\n\n",ftestnames[i]); - output_string(buffer); + printf("Done with %s\n\n",ftestnames[i]); } } } @@ -303,33 +231,27 @@ for(i=0;i*sdev) - { is_beaten=i; - sdev_to_beat=*sdev; - } - } - - if(is_beaten!=-1) - { scores[is_beaten]=*newscore; - return(-1); - } - return(0); - } -#endif - /******************** ** calc_confidence ** ********************* @@ -918,7 +759,7 @@ double student_t[30]={0.0 , 12.706 , 4.303 , 3.182 , 2.776 , 2.571 , 2.056 , 2.052 , 2.048 , 2.045 }; int i; /* Index */ if ((num_scores<2) || (num_scores>30)) { - output_string("Internal error: calc_confidence called with an illegal number of scores\n"); + puts("Internal error: calc_confidence called with an illegal number of scores"); return(-1); } /* @@ -953,15 +794,12 @@ return(0); ************** ** Return the score for a particular benchmark. */ -static double getscore(int fid) -{ - -/* -** Fid tells us the function. This is really a matter of -** doing the proper coercion. -*/ -switch(fid) -{ +static double getscore(int fid) { + /* + ** Fid tells us the function. This is really a matter of + ** doing the proper coercion. + */ + switch(fid) { case TF_NUMSORT: return(global_numsortstruct.sortspersec); case TF_SSORT: @@ -982,25 +820,8 @@ switch(fid) return(global_nnetstruct.iterspersec); case TF_LU: return(global_lustruct.iterspersec); -} -return((double)0.0); -} - -/****************** -** output_string ** -******************* -** Displays a string on the screen. Also, if the flag -** write_to_file is set, outputs the string to the output file. -** Note, this routine presumes that you've included a carriage -** return at the end of the buffer. -*/ -static void output_string(char *buffer) -{ - -printf("%s",buffer); -if(write_to_file!=0) - fprintf(global_ofile,"%s",buffer); -return; + } + return 0.0; } /*************** @@ -1009,166 +830,44 @@ return; ** This routine displays statistics for a particular benchmark. ** The benchmark is identified by its id. */ -static void show_stats (int bid) -{ -char buffer[80]; /* Display buffer */ - -switch(bid) -{ - case TF_NUMSORT: /* Numeric sort */ - sprintf(buffer," Number of arrays: %d\n", - global_numsortstruct.numarrays); - output_string(buffer); - sprintf(buffer," Array size: %ld\n", - global_numsortstruct.arraysize); - output_string(buffer); +static void show_stats (int bid) { + switch(bid) { + case TF_NUMSORT: /* Numeric sort */ + printf(" Number of arrays: %d\n", global_numsortstruct.numarrays); + printf(" Array size: %ld\n", global_numsortstruct.arraysize); break; - case TF_SSORT: /* String sort */ - sprintf(buffer," Number of arrays: %d\n", - global_strsortstruct.numarrays); - output_string(buffer); - sprintf(buffer," Array size: %ld\n", - global_strsortstruct.arraysize); - output_string(buffer); + printf(" Number of arrays: %d\n", global_strsortstruct.numarrays); + printf(" Array size: %ld\n", global_strsortstruct.arraysize); break; - case TF_BITOP: /* Bitmap operation */ - sprintf(buffer," Operations array size: %ld\n", - global_bitopstruct.bitoparraysize); - output_string(buffer); - sprintf(buffer," Bitfield array size: %ld\n", - global_bitopstruct.bitfieldarraysize); - output_string(buffer); + printf(" Operations array size: %ld\n", global_bitopstruct.bitoparraysize); + printf(" Bitfield array size: %ld\n", global_bitopstruct.bitfieldarraysize); break; - case TF_FPEMU: /* Floating-point emulation */ - sprintf(buffer," Number of loops: %lu\n", - global_emfloatstruct.loops); - output_string(buffer); - sprintf(buffer," Array size: %lu\n", - global_emfloatstruct.arraysize); - output_string(buffer); + printf(" Number of loops: %lu\n", global_emfloatstruct.loops); + printf(" Array size: %lu\n", global_emfloatstruct.arraysize); break; - case TF_FFPU: /* Fourier test */ - sprintf(buffer," Number of coefficients: %lu\n", - global_fourierstruct.arraysize); - output_string(buffer); + printf(" Number of coefficients: %lu\n", global_fourierstruct.arraysize); break; - case TF_ASSIGN: - sprintf(buffer," Number of arrays: %lu\n", - global_assignstruct.numarrays); - output_string(buffer); + printf(" Number of arrays: %lu\n", global_assignstruct.numarrays); break; - case TF_IDEA: - sprintf(buffer," Array size: %lu\n", - global_ideastruct.arraysize); - output_string(buffer); - sprintf(buffer," Number of loops: %lu\n", - global_ideastruct.loops); - output_string(buffer); + printf(" Array size: %lu\n", global_ideastruct.arraysize); + printf(" Number of loops: %lu\n", global_ideastruct.loops); break; - case TF_HUFF: - sprintf(buffer," Array size: %lu\n", - global_huffstruct.arraysize); - output_string(buffer); - sprintf(buffer," Number of loops: %lu\n", - global_huffstruct.loops); - output_string(buffer); + printf(" Array size: %lu\n", global_huffstruct.arraysize); + printf(" Number of loops: %lu\n", global_huffstruct.loops); break; - case TF_NNET: - sprintf(buffer," Number of loops: %lu\n", - global_nnetstruct.loops); - output_string(buffer); + printf(" Number of loops: %lu\n", global_nnetstruct.loops); break; - case TF_LU: - sprintf(buffer," Number of arrays: %lu\n", - global_lustruct.numarrays); - output_string(buffer); + printf(" Number of arrays: %lu\n", global_lustruct.numarrays); break; -} -return; -} - -/* -** Following code added for Mac stuff, so that we can emulate command -** lines. -*/ - -#ifdef MAC - -/***************** -** UCommandLine ** -****************** -** Reads in a command line, and sets up argc and argv appropriately. -** Note that this routine uses gets() to read in the line. This means -** you'd better not enter more than 128 characters on a command line, or -** things will overflow, and oh boy... -*/ -void UCommandLine(void) -{ -printf("Enter command line\n:"); -gets((char *)Uargbuff); -UParse(); -return; -} - -/*********** -** UParse ** -************ -** Parse the pseudo command-line. This code appeared as part of the -** Small-C library in Dr. Dobb's ToolBook of C. -** It expects the following globals: -** argc = arg count -** argv = Pointer to array of char pointers -** Uargbuff = Character array that holds the arguments. Should be 129 bytes long. -** Udummy1 = This is a 2-byte buffer that holds a "*", and acts as the first -** argument in the argument list. This maintains compatibility with other -** C's, though it does not provide access to the executable filename. -** This routine allows for up to 20 individual command-line arguments. -** Also note that this routine does NOT allow for redirection. -*/ -void UParse(void) -{ -unsigned char *ptr; - -argc=0; /* Start arg count */ -Udummy[0]='*'; /* Set dummy first argument */ -Udummy[1]='\0'; -argv[argc++]=(char *)Udummy; - -ptr=Uargbuff; /* Start pointer */ -while(*ptr) -{ - if(isspace(*ptr)) - { ++ptr; - continue; } - if(argc<20) argv[argc++]=(char *)ptr; - ptr=UField(ptr); + return; } -return; -} -/*********** -** UField ** -************ -** Isolate the next command-line field. -*/ -unsigned char *UField(unsigned char *ptr) -{ -while(*ptr) -{ if(isspace(*ptr)) - { *ptr=(unsigned char)NULL; - return(++ptr); - } - ++ptr; -} -return(ptr); -} -#endif -- cgit v1.2.3