summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-11-14 23:03:36 +0000
committerMatt Turner <mattst88@gmail.com>2008-11-14 23:03:36 +0000
commit34edabbf495e0222c59937973ab2bfecc8e32dd6 (patch)
treecb3f1660f1fdac73e1f7281d25cb35b68a7db1aa
parent7225b0865e8c7697fce69224640142374b22364d (diff)
Remove adjust struct member in favor of a local static variable
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@44 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
-rw-r--r--assignment.c13
-rw-r--r--bitfield.c12
-rw-r--r--cleanbench.c19
-rw-r--r--fourier.c12
-rw-r--r--fpemulation.c5
-rw-r--r--huffman.c10
-rw-r--r--idea.c28
-rw-r--r--linear.c6
-rw-r--r--neural.c5
-rw-r--r--nmglobal.h9
-rw-r--r--numsort.c13
-rw-r--r--stringsort.c6
12 files changed, 50 insertions, 88 deletions
diff --git a/assignment.c b/assignment.c
index dd18370..26af1f7 100644
--- a/assignment.c
+++ b/assignment.c
@@ -72,18 +72,15 @@ DoAssign(void)
const char* context = "CPU:Assignment";
AssignStruct* locassignstruct = &global_assignstruct; /* Local structure ptr */
long* array = NULL;
- unsigned long total_time = 0;
+ clock_t total_time = 0;
int iterations = 0;
-
int num_arrays = 1;
+ static int is_adjusted = FALSE;
- /*
- ** See if we need to do self adjustment code.
- */
- if (locassignstruct->adjust == FALSE) {
- locassignstruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
/*
- ** Self-adjustment code. The system begins by working on 1
+ ** Self-is_adjustedment code. The system begins by working on 1
** array. If it does that in no time, then two arrays
** are built. This process continues until
** enough arrays are built to handle the tolerance.
diff --git a/bitfield.c b/bitfield.c
index 9a74b97..fcab172 100644
--- a/bitfield.c
+++ b/bitfield.c
@@ -37,17 +37,15 @@ DoBitops(void)
{
const char* context = "CPU:Bitfields";
BitOpStruct* locbitopstruct = &global_bitopstruct;
- clock_t total_time = 0;
- int iterations = 0;
unsigned long* bitarraybase = NULL;
unsigned long* bitoparraybase = NULL;
+ clock_t total_time = 0;
+ int iterations = 0;
unsigned long nbitops;
+ static int is_adjusted = FALSE;
- /*
- ** See if we need to run adjustment code.
- */
- if (locbitopstruct->adjust == FALSE) {
- locbitopstruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
bitarraybase = realloc(bitarraybase, locbitopstruct->bitfieldarraysize * sizeof(unsigned long));
if (!bitarraybase) {
diff --git a/cleanbench.c b/cleanbench.c
index 2d8ed12..565a7d5 100644
--- a/cleanbench.c
+++ b/cleanbench.c
@@ -77,32 +77,13 @@ for (i = 0; i < NUMTESTS; i++) {
** Initialize test data structures to default
** values.
*/
-global_numsortstruct.adjust=0;
global_numsortstruct.arraysize=NUMARRAYSIZE;
-
-global_strsortstruct.adjust=0;
global_strsortstruct.arraysize=STRINGARRAYSIZE;
-
-global_bitopstruct.adjust=0;
global_bitopstruct.bitfieldarraysize=BITFARRAYSIZE;
-
-global_emfloatstruct.adjust=0;
global_emfloatstruct.arraysize=EMFARRAYSIZE;
-
-global_fourierstruct.adjust=0;
-
-global_assignstruct.adjust=0;
-
-global_ideastruct.adjust=0;
global_ideastruct.arraysize=IDEAARRAYSIZE;
-
-global_huffstruct.adjust=0;
global_huffstruct.arraysize=HUFFARRAYSIZE;
-global_nnetstruct.adjust=0;
-
-global_lustruct.adjust=0;
-
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)");
diff --git a/fourier.c b/fourier.c
index 00b0ad0..81ec5b2 100644
--- a/fourier.c
+++ b/fourier.c
@@ -39,16 +39,14 @@ DoFourier(void)
{
const char* context = "FPU:Transcendental";
FourierStruct* locfourierstruct = &global_fourierstruct;
- clock_t total_time = 0;
- int iterations = 0;
double* abase = NULL;
double* bbase = NULL;
+ clock_t total_time = 0;
+ int iterations = 0;
+ static int is_adjusted = FALSE;
- /*
- ** See if we need to do self-adjustment code.
- */
- if (locfourierstruct->adjust == FALSE) {
- locfourierstruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
locfourierstruct->arraysize = 100L; /* Start at 100 elements */
while (1) {
diff --git a/fpemulation.c b/fpemulation.c
index 2fca455..234c1ec 100644
--- a/fpemulation.c
+++ b/fpemulation.c
@@ -36,6 +36,7 @@ DoEmFloat(void)
clock_t total_time = 0;
int iterations = 0;
unsigned long loops = 1;
+ static int is_adjusted = FALSE;
abase = malloc(locemfloatstruct->arraysize * sizeof(InternalFPF));
if (!abase) {
@@ -62,8 +63,8 @@ DoEmFloat(void)
SetupCPUEmFloatArrays(abase, bbase, locemfloatstruct->arraysize); /* FIXME: ugly */
/* See if we need to do self-adjusting code.*/
- if (locemfloatstruct->adjust == FALSE) {
- locemfloatstruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
locemfloatstruct->loops = 0;
diff --git a/huffman.c b/huffman.c
index c6c85e7..168f29a 100644
--- a/huffman.c
+++ b/huffman.c
@@ -62,12 +62,12 @@ DoHuffman(void)
{
const char* context = "CPU:Huffman";
HuffStruct* lochuffstruct = &global_huffstruct;
- clock_t total_time = 0;
- int iterations = 0;
char* comparray = NULL;
char* decomparray = NULL;
char* plaintext = NULL;
-
+ clock_t total_time = 0;
+ int iterations = 0;
+ static int is_adjusted = FALSE;
/*
** Allocate memory for the plaintext and the compressed text.
@@ -127,8 +127,8 @@ DoHuffman(void)
/*
** See if we need to perform self adjustment loop.
*/
- if (lochuffstruct->adjust == FALSE) {
- lochuffstruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
/*
** Do self-adjustment. This involves initializing the
** # of loops and increasing the loop count until we
diff --git a/idea.c b/idea.c
index 335e1e5..2bc7f9b 100644
--- a/idea.c
+++ b/idea.c
@@ -59,20 +59,18 @@ static void cipher_idea(uint16_t in[4], uint16_t out[4], IDEAkey Z);
void
DoIDEA(void)
{
- const char *context = "CPU:IDEA";
- IDEAStruct *locideastruct=&global_ideastruct; /* Loc pointer to global structure */
- clock_t total_time = 0;
- int iterations = 0;
- unsigned char *plain1 = NULL; /* First plaintext buffer */
- unsigned char *crypt1 = NULL; /* Encryption buffer */
- unsigned char *plain2 = NULL; /* Second plaintext buffer */
- IDEAkey Z,DK;
- uint16_t userkey[8];
- int i;
+ const char* context = "CPU:IDEA";
+ IDEAStruct* locideastruct=&global_ideastruct; /* Loc pointer to global structure */
+ unsigned char* plain1 = NULL; /* First plaintext buffer */
+ unsigned char* crypt1 = NULL; /* Encryption buffer */
+ unsigned char* plain2 = NULL; /* Second plaintext buffer */
+ clock_t total_time = 0;
+ int iterations = 0;
+ IDEAkey Z, DK;
+ uint16_t userkey[8];
+ int i;
+ static int is_adjusted = FALSE;
- /*
- ** Re-init random-number generator.
- */
randnum(3);
/*
@@ -129,8 +127,8 @@ DoIDEA(void)
/*
** See if we need to perform self adjustment loop.
*/
- if (locideastruct->adjust == FALSE) {
- locideastruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
/*
** Do self-adjustment. This involves initializing the
** # of loops and increasing the loop count until we
diff --git a/linear.c b/linear.c
index d743f97..656fe43 100644
--- a/linear.c
+++ b/linear.c
@@ -78,8 +78,8 @@ DoLU(void)
LUdblptr ptra;
int n;
int i;
-
int num_arrays;
+ static int is_adjusted = FALSE;
/*
** Our first step is to build a "solvable" problem. This
@@ -109,8 +109,8 @@ DoLU(void)
** auto-adjust. If so, repeatedly call the DoLUIteration routine,
** increasing the number of solutions per iteration as you go.
*/
- if (loclustruct->adjust == FALSE) {
- loclustruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
num_arrays=0;
for(i=1;i<=MAXLUARRAYS;i++)
diff --git a/neural.c b/neural.c
index 5b443d3..ff418ad 100644
--- a/neural.c
+++ b/neural.c
@@ -121,6 +121,7 @@ DoNNET(void)
NNetStruct* locnnetstruct = &global_nnetstruct;
clock_t total_time = 0;
int iterations = 0;
+ static int is_adjusted = FALSE;
/*
** Init random number generator.
@@ -144,8 +145,8 @@ DoNNET(void)
/*
** See if we need to perform self adjustment loop.
*/
- if (locnnetstruct->adjust == FALSE) {
- locnnetstruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
/*
** Do self-adjustment. This involves initializing the
** # of loops and increasing the loop count until we
diff --git a/nmglobal.h b/nmglobal.h
index 7333ca4..2f1018d 100644
--- a/nmglobal.h
+++ b/nmglobal.h
@@ -66,7 +66,6 @@
*/
typedef struct {
double results; /* # of sort iterations per sec */
- int adjust; /* Set adjust code */
unsigned long arraysize; /* # of elements in array */
} SortStruct;
@@ -112,7 +111,6 @@ typedef struct {
*/
typedef struct {
double results; /* # of bitfield ops per sec */
- int adjust; /* Set adjust code */
unsigned long bitoparraysize; /* Total # of bitfield ops */
unsigned long bitfieldarraysize; /* Bit field array size */
} BitOpStruct;
@@ -145,7 +143,6 @@ typedef struct {
*/
typedef struct {
double results; /* Results */
- int adjust; /* Set adjust code */
unsigned long arraysize; /* Size of array */
unsigned long loops; /* Loops per iterations */
} EmFloatStruct;
@@ -159,7 +156,6 @@ typedef struct {
*/
typedef struct {
double results; /* Results */
- int adjust; /* Set adjust code */
unsigned long arraysize; /* Size of coeff. arrays */
} FourierStruct;
@@ -172,7 +168,6 @@ typedef struct {
*/
typedef struct {
double results; /* Results */
- int adjust; /* Set adjust code */
} AssignStruct;
/********************
@@ -200,7 +195,6 @@ typedef struct {
*/
typedef struct {
double results; /* Results */
- int adjust; /* Set adjust code */
unsigned long arraysize; /* Size of array */
unsigned long loops; /* # of times to convert */
} IDEAStruct;
@@ -237,7 +231,6 @@ typedef struct {
typedef struct {
double results; /* Results */
- int adjust; /* Set adjust code */
unsigned long arraysize; /* Size of array */
unsigned long loops; /* # of times to compress/decompress */
} HuffStruct;
@@ -262,7 +255,6 @@ typedef struct {
*/
typedef struct {
double results; /* Results */
- int adjust; /* Set adjust code */
unsigned long loops; /* # of times to learn */
} NNetStruct;
@@ -287,7 +279,6 @@ typedef struct {
*/
typedef struct {
double results; /* Results */
- int adjust; /* Set adjust code */
} LUStruct;
extern SortStruct global_numsortstruct;
diff --git a/numsort.c b/numsort.c
index 1186d54..70bdd2a 100644
--- a/numsort.c
+++ b/numsort.c
@@ -32,19 +32,16 @@ DoNumSort (void)
{
const char* context = "CPU:Numeric Sort";
SortStruct* numsortstruct = &global_numsortstruct;
+ long* arraybase = NULL;
clock_t total_time = 0;
int iterations = 0;
- long* arraybase = NULL;
-
int num_arrays = 1;
+ static int is_adjusted = FALSE;
- /*
- ** See if we need to do self adjustment code.
- */
- if (numsortstruct->adjust == FALSE) {
- numsortstruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
/*
- ** Self-adjustment code. The system begins by sorting 1
+ ** Self-is_adjustedment code. The system begins by sorting 1
** array. If it does that in no time, then two arrays
** are built and sorted. This process continues until
** enough arrays are built to handle the tolerance.
diff --git a/stringsort.c b/stringsort.c
index c102b54..8c80e21 100644
--- a/stringsort.c
+++ b/stringsort.c
@@ -52,11 +52,11 @@ void DoStringSort(void)
unsigned char* arraybase = NULL;
clock_t total_time = 0;
int iterations = 0;
-
int num_arrays = 1;
+ static int is_adjusted = FALSE;
- if (strsortstruct->adjust == FALSE) {
- strsortstruct->adjust = TRUE;
+ if (is_adjusted == FALSE) {
+ is_adjusted = TRUE;
/*
** Initialize the number of arrays.
*/