ALib C++ Library
Library Version: 2510 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{
18 Statistics stats;
19 ma.GetStatistics(stats);
20
21 NAString result;
23 nf.Flags= NumberFormatFlags(uint8_t(nf.Flags) | uint8_t(NumberFormatFlags::WriteGroupChars));
24 nf.FractionalPartWidth=2;
25 result << "MonoAllocator Usage Statistics:" << NNEW_LINE;
26
27 result << " Allocation Size: " << NDec( stats.AllocSize , &nf ) << NNEW_LINE;
28 result << " Current buffer free: " << NDec( stats.CurrentBufferFree , &nf ) << NNEW_LINE;
29 result << " Current buffer used: " << NDec( ma.DbgGetBuffer()->act
30 - reinterpret_cast<char*>(ma.DbgGetBuffer()) , &nf ) << NNEW_LINE;
31 result << " Current buffer size: " << NDec( stats.CurrentBufferSize , &nf ) << NNEW_LINE;
32 result << " Next buffer size: " << NDec( stats.NextBufferSize , &nf ) << NNEW_LINE;
33 result << " Buffers in use: " << NDec( stats.QtyBuffers , &nf ) << NNEW_LINE;
34 result << " Buffers allocated: " << NDec( stats.QtyBuffers + stats.QtyRecyclables , &nf ) << NNEW_LINE;
35 result << " Heap size in use: " << NDec( stats.HeapSize , &nf ) << NNEW_LINE;
36 result << " Heap size allocated: " << NDec( stats.HeapSize + stats.HeapSizeRecycled , &nf ) << NNEW_LINE;
37 result << " Unused buffer bytes: " << NDec( stats.BufferWaste , &nf );
38 if( stats.QtyBuffers ) result << " (per buffer: " << NDec( stats.QtyBuffers > 1 ? (stats.BufferWaste / (stats.QtyBuffers-1)) : 0, &nf ) << ')';
39 result << NNEW_LINE;
40
41 #if ALIB_DEBUG_MEMORY
42 const DbgStatistics& dbgStats= ma.DbgGetStatistics();
43 result << " Dbg: Allocations: " << NDec( dbgStats.QtyAllocations , &nf ) << NNEW_LINE;
44 result << " Dbg: Non-trivial: " << NDec( dbgStats.QtyAllocations- dbgStats.QtyTrivialAllocations, &nf ) << NNEW_LINE;
45 result << " Dbg: Resets: " << NDec( dbgStats.QtyResets , &nf ) << NNEW_LINE;
46
47 result << " Dbg: #Allocs/buffer: ";
48 if( stats.QtyBuffers == 0 ) { result << "N/A"; ALIB_ASSERT( dbgStats.QtyAllocations == 0, "MONOMEM") }
49 else result << NDec( (dbgStats.QtyAllocations / stats.QtyBuffers ), &nf );
50 result << NNEW_LINE;
51
52 result << " Dbg: Alignm. waste: " << NDec( dbgStats.AlignmentWaste , &nf )
53 << " (" << NDec( double(dbgStats.AlignmentWaste)/double(stats.AllocSize) *100. , &nf ) << "%)"<< NNEW_LINE;
54 result << " Dbg: Qty exceeds: " << NDec( dbgStats.QtyBufferSizeExceeds , &nf ) << NNEW_LINE;
55 #endif // ALIB_DEBUG_MEMORY
56
57 return result;
58}
59#include "ALib.Lang.CIMethods.H"
60} // namespace [alib::monomem]
61#endif // ALIB_STRINGS && ALIB_DEBUG
62
#define ALIB_ASSERT(cond, domain)
Definition alib.inl:1048
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:548
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:653
NumberFormatFlags Flags
The flag field.