MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / testTree

Function testTree

src/common/classes/misc/class_perf.cpp:52–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50using namespace Firebird;
51
52static void testTree()
53{
54 printf("Fill array with test data (%d items)...", TEST_ITEMS);
55 Vector<int, TEST_ITEMS> *v = FB_NEW Vector<int, TEST_ITEMS>();
56 int n = 0;
57 int i;
58 for (i = 0; i < TEST_ITEMS; i++) {
59 n = n * 45578 - 17651;
60 // Fill it with quasi-random values in range 0...TEST_ITEMS-1
61 v->add(((i+n) % TEST_ITEMS + TEST_ITEMS)/2);
62 }
63 printf(" DONE\n");
64 MallocAllocator temp;
65
66 start();
67 BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
68 DefaultComparator<int>, 30, 30> tree30(NULL);
69 for (i = 0; i < TEST_ITEMS; i++)
70 tree30.add((*v)[i]);
71 for (i = 0; i < TEST_ITEMS; i++) {
72 if (tree30.locate((*v)[i]))
73 tree30.fastRemove();
74 }
75 report(30, 30);
76
77 start();
78 BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
79 DefaultComparator<int>, 50, 50> tree50(NULL);
80 for (i = 0; i < TEST_ITEMS; i++)
81 tree50.add((*v)[i]);
82 for (i = 0; i < TEST_ITEMS; i++) {
83 if (tree50.locate((*v)[i]))
84 tree50.fastRemove();
85 }
86 report(50, 50);
87
88 start();
89 BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
90 DefaultComparator<int>, 75, 75> tree75(NULL);
91 for (i = 0; i < TEST_ITEMS; i++)
92 tree75.add((*v)[i]);
93 for (i = 0; i < TEST_ITEMS; i++) {
94 if (tree75.locate((*v)[i]))
95 tree75.fastRemove();
96 }
97 report(75, 75);
98
99 start();
100 BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
101 DefaultComparator<int>, 100, 100> tree100(NULL);
102 for (i = 0; i < TEST_ITEMS; i++)
103 tree100.add((*v)[i]);
104 for (i = 0; i < TEST_ITEMS; i++) {
105 if (tree100.locate((*v)[i]))
106 tree100.fastRemove();
107 }
108 report(100, 100);
109

Callers 1

mainFunction · 0.85

Calls 7

startFunction · 0.70
reportFunction · 0.70
addMethod · 0.45
locateMethod · 0.45
fastRemoveMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected