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

Function testAllocatorMalloc

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

Source from the content-addressed store, hash-verified

240}
241
242static void testAllocatorMalloc()
243{
244 printf("Test reference run for ::malloc...\n");
245 start();
246 MallocAllocator allocator;
247 BePlusTree<AllocItem, AllocItem, MallocAllocator, DefaultKeyValue<AllocItem>, AllocItem> items(&allocator),
248 bigItems(&allocator);
249 // Allocate small items
250 int i, n = 0;
251 for (i = 0; i < ALLOC_ITEMS; i++) {
252 n = n * 47163 - 57412;
253 AllocItem temp = {n, malloc((n % MAX_ITEM_SIZE + MAX_ITEM_SIZE) / 2 + 1)};
254 items.add(temp);
255 }
256 // Deallocate half of small items
257 n = 0;
258 if (items.getFirst()) do {
259 free(items.current().item);
260 n++;
261 } while (n < ALLOC_ITEMS / 2 && items.getNext());
262 // Allocate big items
263 for (i = 0; i < BIG_ITEMS; i++) {
264 n = n * 47163 - 57412;
265 AllocItem temp = {n, malloc((n % BIG_SIZE + BIG_SIZE) / 2 + 1)};
266 bigItems.add(temp);
267 }
268 // Deallocate the rest of small items
269 while (items.getNext()) {
270 free(items.current().item);
271 }
272 // Deallocate big items
273 if (bigItems.getFirst()) do {
274 free(bigItems.current().item);
275 } while (bigItems.getNext());
276 report();
277}
278
279/*static void testAllocatorOldPool()
280{

Callers 1

mainFunction · 0.85

Calls 6

startFunction · 0.70
reportFunction · 0.70
addMethod · 0.45
getFirstMethod · 0.45
currentMethod · 0.45
getNextMethod · 0.45

Tested by

no test coverage detected