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

Function testAllocatorOverhead

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

Source from the content-addressed store, hash-verified

163};
164
165static 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
203static void testAllocatorMemoryPool()
204{

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