std.experimental.allocator.building_blocks.stats_collector
Allocator that collects useful statistics about allocations, both global and per calling point. The statistics collected can be configured statically by choosing combinations of Options appropriately.
Source: std/experimental/allocator/building_blocks/stats_collector.d
Types 2
_Options for StatsCollector defined below. Each enables during compilation one specific counter, statistic, or other piece of information.
Allocator that collects extra data about allocations. Since each piece of information adds size and time overhead, statistics can be individually enabled or disabled through compile-time flags.
All stats of the form numXxx record counts of events occurring, such as calls to functions and specific results. The stats of the form bytesXxx collect cumulative sizes.
In addition, the data callerSize, callerModule, callerFile, callerLine, and callerTime is associated with each specific allocation. This data prefixes each allocation.
private q{
add!"bytesUsed"(result.length);
add!"bytesAllocated"(result.length);
immutable slack = this.goodAllocSize(result.length) - result.length;
add!"bytesSlack"(slack);
up!"numAllocate";
add!"numAllocateOK"(result.length == bytes); // allocating 0 bytes is OK
addPerCall!(f, n, "numAllocate", "numAllocateOK", "bytesAllocated")
(1, result.length == bytes, result.length);
} _updateStatsForAllocateResultstring define(string type, string[] names...)void up(string counter)()void down(string counter)()void[] allocateImpl(string f = null, ulong n = 0)(size_t bytes)void[] alignedAllocateImpl(string f = null, ulong n = 0)(size_t bytes, uint a)bool expandImpl(string f = null, uint n = 0)(ref void[] b, size_t s)bool reallocateImpl(string f = null, uint n = 0)(ref void[] b, size_t s)bool deallocateImpl(string f = null, uint n = 0)(void[] b)void reportStatistics(R)(auto ref R output)Reports per instance statistics to `output` (e.g. `stdout`). The format is simple: one kind and value per line, separated by a colon, e.g. `bytesAllocated:7395404`