Macaulay2 Engine
Loading...
Searching...
No Matches

◆ testMemoryBlock()

bool testMemoryBlock ( )

MemoryBlock tests

Definition at line 56 of file NCGroebnerTest.cpp.

57{
59 for (size_t i = 0; i < 1000; ++i)
60 {
61 size_t sz = 4 + (32343 * i) % 10;
62 auto range = B.allocateArray<int>(sz);
63 for (int j = 0; j < sz; j++)
64 range.first[j] = 100 * i + j;
65 if (i % 93 == 0)
66 {
67 range = B.shrinkLastAllocate(range.first, range.second, range.first + 4);
68 for (int j = 0; j < 4; j++)
69 range.first[j] = 100 * i + j;
70 }
71 if ((range.second - range.first != sz) and (range.second - range.first != 4))
72 return false;
73 // std::cout << "i = " << i << " sz = " << sz << " elems = ";
74 // for (int* a = range.first; a != range.second; ++a)
75 // std::cout << *a << " ";
76 // std::cout << std::endl << "memory usage: " << B.getMemoryUsedInBytes() << std::endl;
77 }
78 return true;
79}
std::pair< T *, T * > shrinkLastAllocate(T *begin, T *end, T *newtop)
std::pair< T *, T * > allocateArray(size_t nelems)
Thin RAII wrapper around memtailor::Arena providing bump-pointer array allocation with optional mutex...

References MemoryBlock::allocateArray(), and MemoryBlock::shrinkLastAllocate().

Referenced by TEST().