diff options
Diffstat (limited to 'src/test.cc')
-rw-r--r-- | src/test.cc | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/src/test.cc b/src/test.cc index c5be9b8..cc84d6a 100644 --- a/src/test.cc +++ b/src/test.cc @@ -18,12 +18,28 @@ void exception(int e, char *msg) exit(-1); } -PriorityList *newlist(void) +PriorityList *newlist(int method) { - return new FHeap; + switch (method) { + case 0: + return new BinHeap; + break; + case 1: + return new BHeap; + break; + case 2: + return new FHeap; + break; + case 3: + return new PLList; + break; + default: + cerr << _("Unknow priority list type: ") << method << endl; + exit(-1); + } } -void DoCombTest(int number) +void DoCombTest(int method, int number) { int i, n; Key_t K, oK; @@ -31,7 +47,7 @@ void DoCombTest(int number) PriorityList *T; cerr << _("Creation of a priority list and adding ") << number << _(" random entrie(s)..."); - T = newlist(); + T = newlist(method); for (i = 1; i <= number; i++) { // T->Insert(rand() % P_INFINITY, NULL); // T->Insert(rand() % 100, NULL); @@ -57,7 +73,7 @@ void DoCombTest(int number) cerr << "Ok.\n"; } -void FullTest(void) +void FullTest(int method) { PriorityList *T; Datas_t Datas; @@ -74,20 +90,20 @@ void FullTest(void) cerr << _("Size of a BinHeap header : ") << sizeof(BinHeap) << endl; cerr << _("Size of a BinHeap cell : ") << sizeof(binheap_t) << endl; - DoCombTest(0); - DoCombTest(30); - DoCombTest(70); - DoCombTest(1000); -// DoCombTest(10000); + DoCombTest(method, 0); + DoCombTest(method, 30); + DoCombTest(method, 70); + DoCombTest(method, 1000); +// DoCombTest(method, 10000); #ifdef BT - DoCombTest(100000); + DoCombTest(method, 100000); #ifdef VBT - DoCombTest(1000000); + DoCombTest(method, 1000000); #endif #endif cerr << _("Creating a priority list and adding keys:\n"); - T = newlist(); + T = newlist(method); for (i = 0; i < 30; i++) { fprintf(stderr, "%i ", N[i]); C1 = T->Insert(N[i], NULL); @@ -134,7 +150,31 @@ void FullTest(void) return; } +void Usage(void) +{ + cerr << _("Usage: testTas [type]\n"); + exit(-1); +} + int main(int argc, char **argv) { - FullTest(); + int method = -1; + + while (--argc) { + argv++; + if ((strlen(*argv) != 1) || (((*argv)[0] < '0' || (*argv)[0] > '3'))) { + cerr << _("Unknow priority list type: ") << *argv << endl; + Usage(); + } + if (method != -1) { + cerr << _("Extra command: ") << *argv << endl; + Usage(); + } + method = (*argv)[0] - '0'; + } + + if (method == -1) + method = 0; + FullTest(method); + return 0; } |