global update in test directory

This commit is contained in:
Jeff Hill
1998-02-05 23:29:18 +00:00
parent a4754b7774
commit f9aae0438f
13 changed files with 265 additions and 119 deletions

View File

@@ -7,7 +7,7 @@ CXXCMPLR = STRICT
PROD_LIBS = Com
TESTPROD := resourceLibTest tsDLListBench tsDLListTest tsDLListTest \
tsSLListBench tsSLListTest minmaxTest tsBTreeBench tsBTreeTest
tsSLListBench tsSLListTest minmaxTest
include $(TOP)/config/RULES.Host

View File

@@ -3,10 +3,10 @@
#include "tsMinMax.h"
main ()
int main ()
{
float f1 = 3.3;
float f2 = 3.4;
float f1 = 3.3f;
float f2 = 3.4f;
float f3;
f3 = tsMin(f1,f2);
@@ -24,5 +24,7 @@ main ()
i3 = tsMax(i1,i2);
assert(i3==i2);
return 0;
}

View File

@@ -3,6 +3,7 @@
#include <assert.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#define INSTANCIATE_RES_LIB_STATIC
#include "resourceLib.h"
@@ -13,6 +14,24 @@
#endif
#endif
void empty();
class albert : public uintId, public tsSLNode<albert> {
public:
albert (resTable<albert,uintId> &atIn, unsigned idIn) :
at(atIn), uintId(idIn) {}
void show (unsigned level)
{
}
void destroy()
{
at.remove(*this);
delete this;
}
private:
resTable<albert,uintId> &at;
};
class fred : public uintId, public tsSLNode<fred> {
public:
fred (const char *pNameIn, unsigned idIn) :
@@ -67,36 +86,36 @@ void jane::testTraverse()
main()
{
unsigned i;
clock_t start, finish;
double duration;
const int LOOPS = 50000;
resTable<fred,uintId> intTbl;
unsigned i;
clock_t start, finish;
double duration;
const int LOOPS = 50000;
resTable<fred,uintId> intTbl;
resTable<jane,stringId> strTbl;
fred fred1("fred1",0x1000a432);
fred fred2("fred2",0x0000a432);
jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
fred *pFred;
jane *pJane;
uintId uintId1(0x1000a432);
uintId uintId2(0x0000a432);
stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
int status;
fred fred1("fred1",0x1000a432);
fred fred2("fred2",0x0000a432);
jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
fred *pFred;
jane *pJane;
uintId uintId1(0x1000a432);
uintId uintId2(0x0000a432);
stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
int status;
status = intTbl.init(8);
if (status) {
return -1;
}
status = intTbl.add(fred1);
assert (!status);
status = intTbl.add(fred2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
status = intTbl.add(fred1);
assert (!status);
status = intTbl.add(fred2);
assert (!status);
start = clock();
for (i=0; i<LOOPS; i++) {
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = intTbl.lookup(uintId1);
@@ -117,16 +136,16 @@ main()
assert(pFred==&fred1);
pFred = intTbl.lookup(uintId2);
assert(pFred==&fred2);
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for integer hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for integer hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec per integer hash lookup\n", duration);
printf("It took %15.10f u sec per integer hash lookup\n", duration);
intTbl.show(10u);
@@ -138,13 +157,13 @@ main()
return -1;
}
status = strTbl.add(jane1);
assert (!status);
status = strTbl.add(jane2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
status = strTbl.add(jane1);
assert (!status);
status = strTbl.add(jane2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
@@ -165,16 +184,16 @@ main()
assert(pJane==&jane1);
pJane = strTbl.lookup(strId2);
assert(pJane==&jane2);
}
finish = clock();
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for string hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for string hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec per string hash lookup\n", duration);
printf("It took %15.10f u sec per string hash lookup\n", duration);
strTbl.show(10u);
strTbl.traverse(&jane::testTraverse);
@@ -182,6 +201,54 @@ main()
strTbl.remove(strId1);
strTbl.remove(strId2);
return 0;
start = clock();
for(i=0; i<LOOPS; i++){
empty();
empty();
empty();
empty();
empty();
empty();
empty();
empty();
empty();
empty();
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for empty subroutines\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec to call an empty subroutine\n", duration);
//
// hash distribution test
//
resTable<albert,uintId> alTbl;
status = alTbl.init(10000);
assert(!status);
for(i=0; i<100000; i++) {
unsigned id = (unsigned) rand();
albert *pa = new albert(alTbl, id);
assert(pa);
status = alTbl.add(*pa);
if (status) {
//
// duplicate ids are possible
// and ignored
//
delete pa;
}
}
alTbl.show(1u);
alTbl.destroyAllEntries();
return 0;
}
void empty()
{
}

View File

@@ -1,8 +1,4 @@
#ifndef CLOCKS_PER_SEC
#define CLOCKS_PER_SEC 1000000
#endif
#include <tsDLList.h>
#include <assert.h>
#include <time.h>
@@ -24,7 +20,7 @@ private:
#define LOOPCOUNT 100000
main ()
int main ()
{
tsDLList<fred> list;
tsDLFwdIter<fred> iter(list);
@@ -59,5 +55,7 @@ main ()
delay = delay/CLOCKS_PER_SEC;
delay = delay/LOOPCOUNT;
printf("delay = %15.10f\n", delay);
return 0;
}

View File

@@ -19,7 +19,7 @@ public:
private:
};
main ()
int main ()
{
tsDLList<fred> list;
tsDLFwdIter<fred> iter(list);
@@ -96,5 +96,7 @@ main ()
janeBwdIter.remove();
}
assert(janeList.count()==0);
return 0;
}

View File

@@ -29,7 +29,7 @@ private:
#define LOOPCOUNT 100000
main ()
int main ()
{
tsSLList<fred> list;
fred *pFred;
@@ -69,5 +69,7 @@ main ()
delay = delay/CLOCKS_PER_SEC;
delay = delay/LOOPCOUNT;
printf("delay = %15.10f\n", delay);
return 0;
}

View File

@@ -19,7 +19,7 @@ public:
private:
};
main ()
int main ()
{
tsSLList<fred> list;
fred *pFred;
@@ -97,5 +97,7 @@ main ()
pFredBack = iter();
assert(pFredBack==NULL);
}
return 0;
}

View File

@@ -3,10 +3,10 @@
#include "tsMinMax.h"
main ()
int main ()
{
float f1 = 3.3;
float f2 = 3.4;
float f1 = 3.3f;
float f2 = 3.4f;
float f3;
f3 = tsMin(f1,f2);
@@ -24,5 +24,7 @@ main ()
i3 = tsMax(i1,i2);
assert(i3==i2);
return 0;
}

View File

@@ -3,6 +3,7 @@
#include <assert.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#define INSTANCIATE_RES_LIB_STATIC
#include "resourceLib.h"
@@ -13,6 +14,24 @@
#endif
#endif
void empty();
class albert : public uintId, public tsSLNode<albert> {
public:
albert (resTable<albert,uintId> &atIn, unsigned idIn) :
at(atIn), uintId(idIn) {}
void show (unsigned level)
{
}
void destroy()
{
at.remove(*this);
delete this;
}
private:
resTable<albert,uintId> &at;
};
class fred : public uintId, public tsSLNode<fred> {
public:
fred (const char *pNameIn, unsigned idIn) :
@@ -67,36 +86,36 @@ void jane::testTraverse()
main()
{
unsigned i;
clock_t start, finish;
double duration;
const int LOOPS = 50000;
resTable<fred,uintId> intTbl;
unsigned i;
clock_t start, finish;
double duration;
const int LOOPS = 50000;
resTable<fred,uintId> intTbl;
resTable<jane,stringId> strTbl;
fred fred1("fred1",0x1000a432);
fred fred2("fred2",0x0000a432);
jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
fred *pFred;
jane *pJane;
uintId uintId1(0x1000a432);
uintId uintId2(0x0000a432);
stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
int status;
fred fred1("fred1",0x1000a432);
fred fred2("fred2",0x0000a432);
jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
fred *pFred;
jane *pJane;
uintId uintId1(0x1000a432);
uintId uintId2(0x0000a432);
stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
int status;
status = intTbl.init(8);
if (status) {
return -1;
}
status = intTbl.add(fred1);
assert (!status);
status = intTbl.add(fred2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
status = intTbl.add(fred1);
assert (!status);
status = intTbl.add(fred2);
assert (!status);
start = clock();
for (i=0; i<LOOPS; i++) {
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = intTbl.lookup(uintId1);
@@ -117,16 +136,16 @@ main()
assert(pFred==&fred1);
pFred = intTbl.lookup(uintId2);
assert(pFred==&fred2);
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for integer hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for integer hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec per integer hash lookup\n", duration);
printf("It took %15.10f u sec per integer hash lookup\n", duration);
intTbl.show(10u);
@@ -138,13 +157,13 @@ main()
return -1;
}
status = strTbl.add(jane1);
assert (!status);
status = strTbl.add(jane2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
status = strTbl.add(jane1);
assert (!status);
status = strTbl.add(jane2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
@@ -165,16 +184,16 @@ main()
assert(pJane==&jane1);
pJane = strTbl.lookup(strId2);
assert(pJane==&jane2);
}
finish = clock();
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for string hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for string hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec per string hash lookup\n", duration);
printf("It took %15.10f u sec per string hash lookup\n", duration);
strTbl.show(10u);
strTbl.traverse(&jane::testTraverse);
@@ -182,6 +201,54 @@ main()
strTbl.remove(strId1);
strTbl.remove(strId2);
return 0;
start = clock();
for(i=0; i<LOOPS; i++){
empty();
empty();
empty();
empty();
empty();
empty();
empty();
empty();
empty();
empty();
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for empty subroutines\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec to call an empty subroutine\n", duration);
//
// hash distribution test
//
resTable<albert,uintId> alTbl;
status = alTbl.init(10000);
assert(!status);
for(i=0; i<100000; i++) {
unsigned id = (unsigned) rand();
albert *pa = new albert(alTbl, id);
assert(pa);
status = alTbl.add(*pa);
if (status) {
//
// duplicate ids are possible
// and ignored
//
delete pa;
}
}
alTbl.show(1u);
alTbl.destroyAllEntries();
return 0;
}
void empty()
{
}

View File

@@ -1,8 +1,4 @@
#ifndef CLOCKS_PER_SEC
#define CLOCKS_PER_SEC 1000000
#endif
#include <tsDLList.h>
#include <assert.h>
#include <time.h>
@@ -24,7 +20,7 @@ private:
#define LOOPCOUNT 100000
main ()
int main ()
{
tsDLList<fred> list;
tsDLFwdIter<fred> iter(list);
@@ -59,5 +55,7 @@ main ()
delay = delay/CLOCKS_PER_SEC;
delay = delay/LOOPCOUNT;
printf("delay = %15.10f\n", delay);
return 0;
}

View File

@@ -19,7 +19,7 @@ public:
private:
};
main ()
int main ()
{
tsDLList<fred> list;
tsDLFwdIter<fred> iter(list);
@@ -96,5 +96,7 @@ main ()
janeBwdIter.remove();
}
assert(janeList.count()==0);
return 0;
}

View File

@@ -29,7 +29,7 @@ private:
#define LOOPCOUNT 100000
main ()
int main ()
{
tsSLList<fred> list;
fred *pFred;
@@ -69,5 +69,7 @@ main ()
delay = delay/CLOCKS_PER_SEC;
delay = delay/LOOPCOUNT;
printf("delay = %15.10f\n", delay);
return 0;
}

View File

@@ -19,7 +19,7 @@ public:
private:
};
main ()
int main ()
{
tsSLList<fred> list;
fred *pFred;
@@ -97,5 +97,7 @@ main ()
pFredBack = iter();
assert(pFredBack==NULL);
}
return 0;
}