| 163 | }; |
| 164 | |
| 165 | static void testAllocatorOverhead() |
| 166 | { |
| 167 | printf("Calculating measurement overhead...\n"); |
| 168 | start(); |
| 169 | MallocAllocator allocator; |
| 170 | BePlusTree<AllocItem, AllocItem, MallocAllocator, DefaultKeyValue<AllocItem>, AllocItem> items(&allocator), |
| 171 | bigItems(&allocator); |
| 172 | // Allocate small items |
| 173 | int n = 0; |
| 174 | int i; |
| 175 | for (i = 0; i < ALLOC_ITEMS; i++) { |
| 176 | n = n * 47163 - 57412; |
| 177 | AllocItem temp = {n, (void*)(long)i}; |
| 178 | items.add(temp); |
| 179 | } |
| 180 | // Deallocate half of small items |
| 181 | n = 0; |
| 182 | if (items.getFirst()) do { |
| 183 | items.current(); |
| 184 | n++; |
| 185 | } while (n < ALLOC_ITEMS / 2 && items.getNext()); |
| 186 | // Allocate big items |
| 187 | for (i = 0; i < BIG_ITEMS; i++) { |
| 188 | n = n * 47163 - 57412; |
| 189 | AllocItem temp = {n, (void*)(long)i}; |
| 190 | bigItems.add(temp); |
| 191 | } |
| 192 | // Deallocate the rest of small items |
| 193 | while (items.getNext()) { |
| 194 | items.current(); |
| 195 | } |
| 196 | // Deallocate big items |
| 197 | if (bigItems.getFirst()) do { |
| 198 | bigItems.current(); |
| 199 | } while (bigItems.getNext()); |
| 200 | report(); |
| 201 | } |
| 202 | |
| 203 | static void testAllocatorMemoryPool() |
| 204 | { |