From 715f9e55d9af912cc193f79328024c1af9e5e25f Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sat, 15 Nov 2008 04:02:27 +0000 Subject: Begin major cleanup of cleanbench.c git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@55 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- cleanbench.c | 322 ++++++++++++++++++++++------------------------------------- hardware.c | 15 --- 2 files changed, 119 insertions(+), 218 deletions(-) diff --git a/cleanbench.c b/cleanbench.c index f50b10a..7e8d0ad 100644 --- a/cleanbench.c +++ b/cleanbench.c @@ -1,47 +1,3 @@ - -/* -** cleanbench.c -*/ - -/******************************************* -** BYTEmark (tm) ** -** BYTE MAGAZINE'S NATIVE MODE BENCHMARKS ** -** FOR CPU/FPU ** -** ver 2.0 ** -** Rick Grehan, BYTE Magazine ** -******************************************** -** 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 @@ -53,9 +9,10 @@ static int bench_with_confidence(int fid, double *mean, double *stdev, unsigned long *numtries); static int calc_confidence(double scores[], int num_scores, double *c_half_interval,double *smean, double *sdev); -static double getscore(int fid); +static double getScore(int fid); + +#define NUMTESTS 10 -/* Tests-to-do flags...must coincide with test. */ enum { NUMSORT, STRINGSORT, @@ -69,159 +26,106 @@ enum { LINEAR } tests_t; -#define NUMTESTS 10 - -/* -** Following array is a collection of flags indicating which -** tests to perform. -*/ -int tests_to_do[NUMTESTS]; - - -/* -** Test names -*/ -char *ftestnames[] = { - "NUMERIC SORT ", - "STRING SORT ", - "BITFIELD ", - "FP EMULATION ", - "FOURIER ", - "ASSIGNMENT ", - "IDEA ", - "HUFFMAN ", - "NEURAL NET ", - "LU DECOMPOSITION" }; - -/* -** Indexes -- Baseline is DELL Pentium XP90 -** 11/28/94 -*/ -double bindex[] = { - 38.993, /* Numeric sort */ - 2.238, /* String sort */ - 5829704, /* Bitfield */ - 2.084, /* FP Emulation */ - 879.278, /* Fourier */ - .2628, /* Assignment */ - 65.382, /* IDEA */ - 36.062, /* Huffman */ - .6225, /* Neural Net */ - 19.3031 }; /* LU Decomposition */ - -/* -** Indices -- Baseline is a AMD K6-233, 32MB RAM (60ns SDRAM),512k L2 cache, -** Linux kernel 2.0.32, libc-5.4.38, gcc-2.7.2.3) -** Nov/30/97 -*/ -double lx_bindex[] = { - 118.73, /* Numeric sort */ - 14.459, /* String sort */ - 27910000, /* Bitfield */ - 9.0314, /* FP Emulation */ - 1565.5, /* Fourier */ - 1.0132, /* Assignment */ - 220.21, /* IDEA */ - 112.93, /* Huffman */ - 1.4799, /* Neural Net */ - 26.732}; /* LU Decomposition */ +int +main(int argc, char *argv[]) +{ + const char* test_name[] = { + "NUMERIC SORT ", + "STRING SORT ", + "BITFIELD ", + "FP EMULATION ", + "FOURIER ", + "ASSIGNMENT ", + "IDEA ", + "HUFFMAN ", + "NEURAL NET ", + "LU DECOMPOSITION" + }; + /* + ** Indexes -- Baseline is DELL Pentium XP90 + ** 11/28/94 + */ + const double bindex[] = { + 38.993, /* Numeric sort */ + 2.238, /* String sort */ + 5829704, /* Bitfield */ + 2.084, /* FP Emulation */ + 879.278, /* Fourier */ + 0.2628, /* Assignment */ + 65.382, /* IDEA */ + 36.062, /* Huffman */ + 0.6225, /* Neural Net */ + 19.3031 /* LU Decomposition */ + }; -void (*funcpointer[])(void) = -{ DoNumSort, - DoStringSort, - DoBitops, - DoEmFloat, - DoFourier, - DoAssign, - DoIDEA, - DoHuffman, - DoNNET, - DoLU }; + /* + ** Indices -- Baseline is a AMD K6-233, 32MB RAM (60ns SDRAM),512k L2 cache, + ** Linux kernel 2.0.32, libc-5.4.38, gcc-2.7.2.3) + ** Nov/30/97 + */ + const double linux_bindex[] = { + 118.73, /* Numeric sort */ + 14.459, /* String sort */ + 27910000, /* Bitfield */ + 9.0314, /* FP Emulation */ + 1565.5, /* Fourier */ + 1.0132, /* Assignment */ + 220.21, /* IDEA */ + 112.93, /* Huffman */ + 1.4799, /* Neural Net */ + 26.732 /* LU Decomposition */ + }; -/************* -**** main **** -*************/ -int main(int argc, char *argv[]) { -double bmean; /* Benchmark mean */ -double bstdev; /* Benchmark stdev */ -double lx_memindex = 1.0; /* Linux memory index (mainly integer operations)*/ -double lx_intindex = 1.0; /* Linux integer index */ -double lx_fpindex = 1.0; /* Linux floating-point index */ -double intindex = 1.0; /* Integer index */ -double fpindex = 1.0; /* Floating-point index */ -unsigned long bnumrun; /* # of runs */ -int i; /* Index */ + double linux_memindex = 1.0; /* Linux memory index (mainly integer operations)*/ + double linux_intindex = 1.0; /* Linux integer index */ + double linux_fpindex = 1.0; /* Linux floating-point index */ + double intindex = 1.0; /* Integer index */ + double fpindex = 1.0; /* Floating-point index */ + double bmean; /* Benchmark mean */ + double bstdev; /* Benchmark stdev */ + unsigned long bnumrun; /* # of runs */ + int test; /* Index */ -/* -** We presume all tests will be run unless told -** otherwise -*/ -for (i = 0; i < NUMTESTS; i++) { - tests_to_do[i] = TRUE; -} + puts( "TEST : Iterations/sec. : Old Index : New Index\n" + " : : Pentium 90* : AMD K6/233*" + "--------------------:------------------:-------------:------------"); -puts("BYTEmark* 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)"); -puts("\nTEST : Iterations/sec. : Old Index : New Index"); -puts(" : : Pentium 90* : AMD K6/233*"); -puts("--------------------:------------------:-------------:------------"); + for (test = NUMSORT; test < NUMTESTS; test++) { + printf("%s :", test_name[test]); + + if (!bench_with_confidence(test, &bmean, &bstdev, &bnumrun)) { + printf( "\n** WARNING: The current test result is NOT 95 % statistically certain.\n" + "** WARNING: The variation among the individual results is too large.\n" + " :"); + } + printf(" %15.5g : %9.2f : %9.2f\n", bmean, bmean / bindex[test], bmean / linux_bindex[test]); -for(i=NUMSORT;i30)) { puts("Internal error: calc_confidence called with an illegal number of scores"); - return(-1); + return TRUE; } /* ** First calculate mean. @@ -353,15 +269,15 @@ for(i=0;i