1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-15 23:12:44 +01:00

Keep some stats

This commit is contained in:
Eelco Dolstra 2019-04-24 13:46:34 +02:00
parent 80accdcebe
commit 14f7a60755
2 changed files with 10 additions and 1 deletions

View file

@ -44,7 +44,10 @@ GC::GC()
GC::~GC()
{
debug("allocated %d bytes in total", totalSize * WORD_SIZE);
printInfo("%d bytes in arenas, %d bytes allocated, %d bytes reclaimed by GC",
totalSize * WORD_SIZE,
allTimeWordsAllocated * WORD_SIZE,
allTimeWordsFreed * WORD_SIZE);
size_t n = 0;
for (Ptr<Object> * p = frontPtrSentinel->next; p != backPtrSentinel; p = p->next)
@ -250,6 +253,8 @@ void GC::gc()
debug("freed %d bytes in %d dead objects, keeping %d objects",
totalWordsFreed * WORD_SIZE, totalObjectsFreed, marked);
allTimeWordsFreed += totalWordsFreed;
}
std::pair<size_t, size_t> GC::freeUnmarked(Arena & arena)

View file

@ -188,6 +188,9 @@ private:
std::array<FreeList, 8> freeLists;
size_t allTimeWordsAllocated = 0;
size_t allTimeWordsFreed = 0;
Object * allocObject(size_t size)
{
assert(size >= 2);
@ -255,6 +258,7 @@ public:
Ptr<T> alloc(size_t size, const Args & ... args)
{
auto raw = allocObject(size);
allTimeWordsAllocated += size;
return new (raw) T(args...);
}