ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
strings_monomem.t.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This "template-definition-header" file is part of module \alib_monomem of the \aliblong.
4/// It may be used to instantiate custom versions of \alib{monomem;TPoolAllocator}, working with
5/// a different \ref alib_contmono_chaining "chained" allocator.
6/// @see Manual section \ref alib_manual_appendix_t_inl_files about the nature of ".t.inl"-files.
7///
8/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
9/// Published under \ref mainpage_license "Boost Software License".
10//==================================================================================================
11#if ALIB_STRINGS && ALIB_DEBUG && !DOXYGEN
12namespace alib::monomem {
14
15template<typename TAllocator>
17 Statistics stats;
18 ma.GetStatistics(stats);
19
20 NAString result;
22 nf.Flags= NumberFormatFlags(uint8_t(nf.Flags) | uint8_t(NumberFormatFlags::WriteGroupChars));
23 nf.FractionalPartWidth=2;
24 result << "MonoAllocator Usage Statistics:" << NNEW_LINE;
25
26 result << " Allocation Size: " << NDec( stats.AllocSize , &nf ) << NNEW_LINE;
27 result << " Current buffer free: " << NDec( stats.CurrentBufferFree , &nf ) << NNEW_LINE;
28 result << " Current buffer used: " << NDec( ma.DbgGetBuffer()->act
29 - reinterpret_cast<char*>(ma.DbgGetBuffer()) , &nf ) << NNEW_LINE;
30 result << " Current buffer size: " << NDec( stats.CurrentBufferSize , &nf ) << NNEW_LINE;
31 result << " Next buffer size: " << NDec( stats.NextBufferSize , &nf ) << NNEW_LINE;
32 result << " Buffers in use: " << NDec( stats.QtyBuffers , &nf ) << NNEW_LINE;
33 result << " Buffers allocated: " << NDec( stats.QtyBuffers + stats.QtyRecyclables , &nf ) << NNEW_LINE;
34 result << " Heap size in use: " << NDec( stats.HeapSize , &nf ) << NNEW_LINE;
35 result << " Heap size allocated: " << NDec( stats.HeapSize + stats.HeapSizeRecycled , &nf ) << NNEW_LINE;
36 result << " Unused buffer bytes: " << NDec( stats.BufferWaste , &nf );
37 if( stats.QtyBuffers ) result << " (per buffer: " << NDec( stats.QtyBuffers > 1 ? (stats.BufferWaste / (stats.QtyBuffers-1)) : 0, &nf ) << ')';
38 result << NNEW_LINE;
39
40 #if ALIB_DEBUG_MEMORY
41 const DbgStatistics& dbgStats= ma.DbgGetStatistics();
42 result << " Dbg: Allocations: " << NDec( dbgStats.QtyAllocations , &nf ) << NNEW_LINE;
43 result << " Dbg: Non-trivial: " << NDec( dbgStats.QtyAllocations- dbgStats.QtyTrivialAllocations, &nf ) << NNEW_LINE;
44 result << " Dbg: Resets: " << NDec( dbgStats.QtyResets , &nf ) << NNEW_LINE;
45
46 result << " Dbg: #Allocs/buffer: ";
47 if( stats.QtyBuffers == 0 ) { result << "N/A"; ALIB_ASSERT( dbgStats.QtyAllocations == 0, "MONOMEM") }
48 else result << NDec( (dbgStats.QtyAllocations / stats.QtyBuffers ), &nf );
49 result << NNEW_LINE;
50
51 result << " Dbg: Alignm. waste: " << NDec( dbgStats.AlignmentWaste , &nf )
52 << " (" << NDec( double(dbgStats.AlignmentWaste)/double(stats.AllocSize) *100. , &nf ) << "%)"<< NNEW_LINE;
53 result << " Dbg: Qty exceeds: " << NDec( dbgStats.QtyBufferSizeExceeds , &nf ) << NNEW_LINE;
54 #endif // ALIB_DEBUG_MEMORY
55
56 return result;
57}
58#include "ALib.Lang.CIMethods.H"
59} // namespace [alib::monomem]
60#endif // ALIB_STRINGS && ALIB_DEBUG
#define ALIB_ASSERT(cond, domain)
Definition alib.inl:1065
NAString DbgDumpStatistics(monomem::TMonoAllocator< TAllocator > &ma)
strings::TNumberFormat< nchar > NNumberFormat
Type alias in namespace alib.
strings::NumberFormatFlags NumberFormatFlags
Type alias in namespace alib.
strings::TDec< nchar > NDec
Type alias in namespace alib.
Definition format.inl:544
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace alib.
constexpr NCString NNEW_LINE
A zero-terminated string containing the new-line character sequence.
Definition cstring.inl:625
NumberFormatFlags Flags
The flag field.