| 1 |
@safe unittest |
| 2 |
{ |
| 3 |
import std.experimental.allocator.building_blocks.stats_collector; |
| 4 |
|
| 5 |
import std.experimental.allocator.gc_allocator : GCAllocator; |
| 6 |
import std.experimental.allocator.building_blocks.free_list : FreeList; |
| 7 |
alias Allocator = StatsCollector!(GCAllocator, Options.bytesUsed); |
| 8 |
} |
| 9 |
|
| 10 |
@system unittest |
| 11 |
{ |
| 12 |
import std.experimental.allocator.building_blocks.stats_collector; |
| 13 |
|
| 14 |
import std.experimental.allocator.building_blocks.free_list : FreeList; |
| 15 |
import std.experimental.allocator.gc_allocator : GCAllocator; |
| 16 |
alias Allocator = StatsCollector!(GCAllocator, Options.all, Options.all); |
| 17 |
|
| 18 |
Allocator alloc; |
| 19 |
auto b = alloc.allocate(10); |
| 20 |
alloc.reallocate(b, 20); |
| 21 |
alloc.deallocate(b); |
| 22 |
|
| 23 |
import std.file : deleteme, remove; |
| 24 |
import std.range : walkLength; |
| 25 |
import std.stdio : File; |
| 26 |
|
| 27 |
auto f = deleteme ~ "-dlang.std.experimental.allocator.stats_collector.txt"; |
| 28 |
scope(exit) remove(f); |
| 29 |
Allocator.reportPerCallStatistics(File(f, "w")); |
| 30 |
alloc.reportStatistics(File(f, "a")); |
| 31 |
assert(File(f).byLine.walkLength == 24); |
| 32 |
} |
| 33 |
|