MCPcopy Create free account
hub / github.com/devosoft/avida / DumpStats

Function DumpStats

libs/tcmalloc-1.4/src/tcmalloc.cc:344–403  ·  view source on GitHub ↗

WRITE stats to "out"

Source from the content-addressed store, hash-verified

342
343// WRITE stats to "out"
344static void DumpStats(TCMalloc_Printer* out, int level) {
345 TCMallocStats stats;
346 uint64_t class_count[kNumClasses];
347 ExtractStats(&stats, (level >= 2 ? class_count : NULL));
348
349 static const double MB = 1048576.0;
350
351 if (level >= 2) {
352 out->printf("------------------------------------------------\n");
353 out->printf("Size class breakdown\n");
354 out->printf("------------------------------------------------\n");
355 uint64_t cumulative = 0;
356 for (unsigned int cl = 0; cl < kNumClasses; ++cl) {
357 if (class_count[cl] > 0) {
358 uint64_t class_bytes =
359 class_count[cl] * Static::sizemap()->ByteSizeForClass(cl);
360 cumulative += class_bytes;
361 out->printf("class %3d [ %8" PRIuS " bytes ] : "
362 "%8" PRIu64 " objs; %5.1f MB; %5.1f cum MB\n",
363 cl, Static::sizemap()->ByteSizeForClass(cl),
364 class_count[cl],
365 class_bytes / MB,
366 cumulative / MB);
367 }
368 }
369
370 SpinLockHolder h(Static::pageheap_lock());
371 Static::pageheap()->Dump(out);
372
373 out->printf("------------------------------------------------\n");
374 DumpSystemAllocatorStats(out);
375 }
376
377 const uint64_t bytes_in_use = stats.system_bytes
378 - stats.pageheap_bytes
379 - stats.central_bytes
380 - stats.transfer_bytes
381 - stats.thread_bytes;
382
383 out->printf("------------------------------------------------\n"
384 "MALLOC: %12" PRIu64 " (%7.1f MB) Heap size\n"
385 "MALLOC: %12" PRIu64 " (%7.1f MB) Bytes in use by application\n"
386 "MALLOC: %12" PRIu64 " (%7.1f MB) Bytes free in page heap\n"
387 "MALLOC: %12" PRIu64 " (%7.1f MB) Bytes free in central cache\n"
388 "MALLOC: %12" PRIu64 " (%7.1f MB) Bytes free in transfer cache\n"
389 "MALLOC: %12" PRIu64 " (%7.1f MB) Bytes free in thread caches\n"
390 "MALLOC: %12" PRIu64 " Spans in use\n"
391 "MALLOC: %12" PRIu64 " Thread heaps in use\n"
392 "MALLOC: %12" PRIu64 " (%7.1f MB) Metadata allocated\n"
393 "------------------------------------------------\n",
394 stats.system_bytes, stats.system_bytes / MB,
395 bytes_in_use, bytes_in_use / MB,
396 stats.pageheap_bytes, stats.pageheap_bytes / MB,
397 stats.central_bytes, stats.central_bytes / MB,
398 stats.transfer_bytes, stats.transfer_bytes / MB,
399 stats.thread_bytes, stats.thread_bytes / MB,
400 uint64_t(Static::span_allocator()->inuse()),
401 uint64_t(ThreadCache::HeapsInUse()),

Callers 2

PrintStatsFunction · 0.85
GetStatsMethod · 0.85

Calls 6

ExtractStatsFunction · 0.85
DumpSystemAllocatorStatsFunction · 0.85
printfMethod · 0.80
ByteSizeForClassMethod · 0.80
inuseMethod · 0.80
DumpMethod · 0.45

Tested by

no test coverage detected