summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-11-15 04:02:27 +0000
committerMatt Turner <mattst88@gmail.com>2008-11-15 04:02:27 +0000
commit715f9e55d9af912cc193f79328024c1af9e5e25f (patch)
tree6fbee73964b1bdf61cd882bb2fabde7f97786422
parenteaf59c0a4f701b19168a34f0c0cb823f59fe1cc6 (diff)
Begin major cleanup of cleanbench.c
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@55 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
-rw-r--r--cleanbench.c322
-rw-r--r--hardware.c15
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 <stdio.h>
#include <stdlib.h>
#include <ctype.h>
@@ -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;i<NUMTESTS;i++)
-{
- if(tests_to_do[i])
- { printf("%s :",ftestnames[i]);
- if (0!=bench_with_confidence(i,
- &bmean,
- &bstdev,
- &bnumrun)){
- puts("\n** WARNING: The current test result is NOT 95 % statistically certain.");
- puts("** WARNING: The variation among the individual results is too large.");
- printf(" :");
- }
- printf(" %15.5g : %9.2f : %9.2f\n",
- bmean,bmean/bindex[i],bmean/lx_bindex[i]);
- /*
- ** Gather integer or FP indexes
- */
- if((i==4)||(i==8)||(i==9)){
- /* FP index */
- fpindex=fpindex*(bmean/bindex[i]);
- /* Linux FP index */
- lx_fpindex=lx_fpindex*(bmean/lx_bindex[i]);
- }
- else{
- /* Integer index */
- intindex=intindex*(bmean/bindex[i]);
- if((i==0)||(i==3)||(i==6)||(i==7))
- /* Linux integer index */
- lx_intindex=lx_intindex*(bmean/lx_bindex[i]);
- else
- /* Linux memory index */
- lx_memindex=lx_memindex*(bmean/lx_bindex[i]);
+ if ((test == FOURIER) || (test == NEURAL) || (test == LINEAR)) {
+ fpindex *= bmean / bindex[test];
+ linux_fpindex *= bmean / linux_bindex[test];
+ } else {
+ intindex *= bmean / bindex[test];
+ if ((test == NUMSORT) || (test == FPEMULATION) || (test == IDEA) || (test == HUFFMAN)) {
+ linux_intindex *= bmean / linux_bindex[test];
+ } else {
+ linux_memindex *= bmean / linux_bindex[test];
+ }
}
}
-}
- 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===============================");
+ printf( "==========================ORIGINAL BYTEMARK RESULTS==========================\n"
+ "INTEGER INDEX : %.3f\n"
+ "FLOATING-POINT INDEX: %.3f\n"
+ "Baseline (MSDOS*) : Pentium* 90, 256 KB L2-cache, Watcom* compiler 10.0\n"
+ "==============================LINUX DATA BELOW===============================\n",
+ pow(intindex, .142857), pow(fpindex, .33333));
hardware();
#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.");
+ printf( "MEMORY INDEX : %.3f\n"
+ "INTEGER INDEX : %.3f\n"
+ "FLOATING-POINT INDEX: %.3f\n"
+ "Baseline (LINUX) : AMD K6/233*, 512 KB L2-cache, gcc 2.7.2.3, libc-5.4.38\n",
+ pow(linux_memindex, .3333333333), pow(linux_intindex, .25), pow(linux_fpindex, .3333333333));
return 0;
}
@@ -240,14 +144,26 @@ puts("* Trademarks are property of their respective holder.");
** along. We simply do more runs and hope to get a big enough sample
** size so that things stabilize. Uwe F. Mayer
**
-** Return 0 if ok, -1 if failure. Returns mean
+** Return TRUE if ok, FALSE if failure. Returns mean
** and std. deviation of results if successful.
*/
-static int bench_with_confidence(int fid, /* Function id */
+static int bench_with_confidence(int benchmark,
double *mean, /* Mean of scores */
double *stdev, /* Standard deviation */
unsigned long *numtries) /* # of attempts */
{
+void (*funcpointer[])(void) =
+{ DoNumSort,
+ DoStringSort,
+ DoBitops,
+ DoEmFloat,
+ DoFourier,
+ DoAssign,
+ DoIDEA,
+ DoHuffman,
+ DoNNET,
+ DoLU };
+
double myscores[30]; /* Need at least 5 scores, use at most 30 */
double c_half_interval; /* Confidence half interval */
int i; /* Index */
@@ -257,8 +173,8 @@ int i; /* Index */
** Get first 5 scores. Then begin confidence testing.
*/
for (i=0;i<5;i++)
-{ (*funcpointer[fid])();
- myscores[i]=getscore(fid);
+{ (*funcpointer[benchmark])();
+ myscores[i]=getScore(benchmark);
}
*numtries=5; /* Show 5 attempts */
@@ -273,13 +189,13 @@ for (i=0;i<5;i++)
while(1)
{
/*
- ** Calculate confidence. Should always return 0.
+ ** Calculate confidence. Should always return TRUE
*/
if (0!=calc_confidence(myscores,
*numtries,
&c_half_interval,
mean,
- stdev)) return(-1);
+ stdev)) return FALSE;
/*
** Is the length of the half interval 5% or less of mean?
@@ -290,13 +206,13 @@ while(1)
/* We now simply add a new test run and hope that the runs
finally stabilize, Uwe F. Mayer */
- if(*numtries==30) return(-1);
- (*funcpointer[fid])();
- myscores[*numtries]=getscore(fid);
+ if(*numtries==30) return FALSE;
+ (*funcpointer[benchmark])();
+ myscores[*numtries]=getScore(benchmark);
*numtries+=1;
}
- return 0;
+ return TRUE;
}
/********************
@@ -327,7 +243,7 @@ double student_t[30]={0.0 , 12.706 , 4.303 , 3.182 , 2.776 , 2.571 ,
int i; /* Index */
if ((num_scores<2) || (num_scores>30)) {
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<num_scores;i++) {
** observations). See any introduction to statistics.
*/
*c_half_interval=student_t[num_scores-1] * (*sdev) / sqrt((double)num_scores);
-return(0);
+return FALSE;
}
/*************
-** getscore **
+** getScore **
**************
** Return the score for a particular benchmark.
*/
-static double getscore(int benchmark) {
+static double getScore(int benchmark) {
double (*getScore[])(void) = {
getNumSortScore,
getStringSortScore,
diff --git a/hardware.c b/hardware.c
index 2508bf8..4faafbd 100644
--- a/hardware.c
+++ b/hardware.c
@@ -145,7 +145,6 @@ static void readProcCpuInfo (char *model, char *cache) {
** Reads /proc/cpuinfo if on a linux system
** Writes output
*/
-#define BUF_SIZ 1024
void hardware(void) {
char os[BUF_SIZ];
@@ -167,17 +166,3 @@ void hardware(void) {
printf("L2 Cache : %s\n", cache);
printf("OS : %s\n", os);
}
-
-
-/************************
-** main for hardware.c **
-*************************
-** For testing of code only
-** Should be commented out
-*/
-/*
-int main(int argc, char * argv[]) {
- hardware(0, NULL);
- return 0;
-}
-*/