diff --git a/src/common/classes/class_perf.cpp b/src/common/classes/class_perf.cpp index f57f4e7a8f..31da5fc822 100644 --- a/src/common/classes/class_perf.cpp +++ b/src/common/classes/class_perf.cpp @@ -24,7 +24,7 @@ * Contributor(s): ______________________________________. * * - * $Id: class_perf.cpp,v 1.13 2004-08-10 04:10:47 skidder Exp $ + * $Id: class_perf.cpp,v 1.14 2004-08-22 21:31:19 skidder Exp $ * */ @@ -41,12 +41,12 @@ void start() { t = clock(); } -const int TEST_ITEMS = 100000; +const int TEST_ITEMS = 5000000; -void report(int scale) { +void report(int scaleNode, int scaleTree) { clock_t d = clock(); - printf("Add+remove %d elements from tree of scale %d took %d milliseconds. \n", - TEST_ITEMS, scale, (int)(d-t)*1000/CLOCKS_PER_SEC); + printf("Add+remove %d elements from tree of scale %d/%d took %d milliseconds. \n", + TEST_ITEMS, scaleNode, scaleTree, (int)(d-t)*1000/CLOCKS_PER_SEC); } using namespace Firebird; @@ -66,14 +66,14 @@ static void testTree() { start(); BePlusTree, - DefaultComparator, 10, 10> tree10(NULL); + DefaultComparator, 30, 30> tree30(NULL); for (i=0; i, @@ -84,7 +84,7 @@ static void testTree() { if (tree50.locate((*v)[i])) tree50.fastRemove(); } - report(50); + report(50, 50); start(); BePlusTree, @@ -95,7 +95,7 @@ static void testTree() { if (tree75.locate((*v)[i])) tree75.fastRemove(); } - report(75); + report(75, 75); start(); BePlusTree, @@ -106,7 +106,18 @@ static void testTree() { if (tree100.locate((*v)[i])) tree100.fastRemove(); } - report(100); + report(100, 100); + + start(); + BePlusTree, + DefaultComparator, 100, 250> tree100_250(NULL); + for (i=0; i, @@ -117,29 +128,7 @@ static void testTree() { if (tree200.locate((*v)[i])) tree200.fastRemove(); } - report(200); - - start(); - BePlusTree, - DefaultComparator, 250, 250> tree250(NULL); - for (i=0; i, - DefaultComparator, 500, 500> tree500(NULL); - for (i=0; i stlTree; start(); @@ -158,7 +147,7 @@ void report() { printf("Operation took %d milliseconds.\n", (int)(d-t)*1000/CLOCKS_PER_SEC); } -const int ALLOC_ITEMS = 10000000; +const int ALLOC_ITEMS = 5000000; const int MAX_ITEM_SIZE = 50; const int BIG_ITEMS = ALLOC_ITEMS / 10; const int BIG_SIZE = MAX_ITEM_SIZE * 5; diff --git a/src/common/classes/class_test.cpp b/src/common/classes/class_test.cpp index 6162926ab3..048f67b9df 100644 --- a/src/common/classes/class_test.cpp +++ b/src/common/classes/class_test.cpp @@ -24,7 +24,7 @@ * Contributor(s): ______________________________________. * * - * $Id: class_test.cpp,v 1.19 2004-08-09 01:24:54 skidder Exp $ + * $Id: class_test.cpp,v 1.20 2004-08-22 21:31:19 skidder Exp $ * */ @@ -366,7 +366,7 @@ void testBePlusTree() { printf(passed ? "PASSED\n" : "FAILED\n"); } -const int ALLOC_ITEMS = 10000; +const int ALLOC_ITEMS = 10000000; const int MAX_ITEM_SIZE = 50; const int BIG_ITEMS = ALLOC_ITEMS / 10; const int BIG_SIZE = MAX_ITEM_SIZE * 5; @@ -374,6 +374,10 @@ const int BIG_SIZE = MAX_ITEM_SIZE * 5; const int LARGE_ITEMS = 10; const size_t LARGE_ITEM_SIZE = 300000; +// Use define to be able to disable some of the checks easily +//#define VERIFY_POOL(pool) pool->verify_pool() +#define VERIFY_POOL(pool) + struct AllocItem { int order; void *item; @@ -394,22 +398,24 @@ void testAllocator() { Vector la; printf("Allocate %d large items: ", LARGE_ITEMS); int i; - for (i = 0; iallocate(LARGE_ITEM_SIZE)); - pool->verify_pool(); + for (i = 0; iallocate(LARGE_ITEM_SIZE)); + VERIFY_POOL(pool); + } + VERIFY_POOL(pool); printf(" DONE\n"); printf("Allocate %d items: ", ALLOC_ITEMS); int n = 0; - pool->verify_pool(); + VERIFY_POOL(pool); for (i = 0; i < ALLOC_ITEMS; i++) { n = n * 47163 - 57412; AllocItem temp = {n, pool->allocate((n % MAX_ITEM_SIZE + MAX_ITEM_SIZE) / 2 + 1)}; items.add(temp); } printf(" DONE\n"); - pool->verify_pool(); - parent->verify_pool(); + VERIFY_POOL(pool); + VERIFY_POOL(parent); printf("Deallocate half of items in quasi-random order: "); n = 0; @@ -418,28 +424,28 @@ void testAllocator() { n++; } while (n < ALLOC_ITEMS / 2 && items.getNext()); printf(" DONE\n"); - pool->verify_pool(); - parent->verify_pool(); + VERIFY_POOL(pool); + VERIFY_POOL(parent); printf("Allocate %d big items: ", BIG_ITEMS); n = 0; - pool->verify_pool(); + VERIFY_POOL(pool); for (i = 0; i < BIG_ITEMS; i++) { n = n * 47163 - 57412; AllocItem temp = {n, pool->allocate((n % BIG_SIZE + BIG_SIZE) / 2 + 1)}; bigItems.add(temp); } printf(" DONE\n"); - pool->verify_pool(); - parent->verify_pool(); + VERIFY_POOL(pool); + VERIFY_POOL(parent); printf("Deallocate the rest of small items in quasi-random order: "); while (items.getNext()) { pool->deallocate(items.current().item); } printf(" DONE\n"); - pool->verify_pool(); - parent->verify_pool(); + VERIFY_POOL(pool); + VERIFY_POOL(parent); printf("Deallocate big items in quasi-random order: "); if (bigItems.getFirst()) do { @@ -450,16 +456,16 @@ void testAllocator() { printf("Deallocate %d large items: ", LARGE_ITEMS/2); for (i = 0; ideallocate(la[i]); - pool->verify_pool(); + VERIFY_POOL(pool); printf(" DONE\n"); - pool->verify_pool(); - parent->verify_pool(); +// pool->verify_pool(); +// parent->verify_pool(); pool->print_contents(stdout, false); parent->print_contents(stdout, false); MemoryPool::deletePool(pool); - parent->verify_pool(); +// parent->verify_pool(); // TODO: // Test critically low memory conditions // Test that tree correctly recovers in low-memory conditions diff --git a/src/common/classes/test.sh b/src/common/classes/test.sh index 683d1406a3..1d1dbf4750 100755 --- a/src/common/classes/test.sh +++ b/src/common/classes/test.sh @@ -2,13 +2,13 @@ # this should be compiled with optimization turned off and with NDEBUG undefined ulimit -s unlimited ulimit -c unlimited -#g++ -ggdb -Wall -I../../include -DTESTING_ONLY -DUSE_VALGRIND class_test.cpp alloc.cpp ../fb_exception.cpp 2> aa +#g++ -ggdb -Wall -I../../include -DTESTING_ONLY -DDEBUG_GDS_ALLOC class_test.cpp alloc.cpp ../fb_exception.cpp 2> aa #valgrind --tool=memcheck ./a.out #export LD_LIBRARY_PATH=/usr/local/lib64 # Chose the best algorithm parameters for the target architecture #/usr/local/bin/ -g++ -O3 -DHAVE_STDLIB_H -DNDEBUG -DTESTING_ONLY \ +g++ -ggdb -O3 -DHAVE_STDLIB_H -DNDEBUG -DTESTING_ONLY \ -I../../include class_perf.cpp alloc.cpp ../fb_exception.cpp 2> aa ./a.out