23 #ifndef ALLOC_MONITOR_H_INCLUDED 24 #define ALLOC_MONITOR_H_INCLUDED 33 using Time = std::clock_t;
43 std::map<Type, data_alloc> DATA{};
45 void record(Type type,
48 if (
auto pos = DATA.find(type); pos == DATA.end()) {
49 DATA[type] = {1, time};
53 DATA[type].time += time;
57 void displayResults(std::ostream& out)
59 for (
const auto& [key, data] : DATA) {
61 out <<
" --> " << data.count <<
" allocations.\n";
62 out <<
" --> " << data.time/CLOCKS_PER_SEC
63 <<
" s of total life time.\n";
74 std::clock_t __allocation_time;
79 __allocation_time = std::clock();
82 void __record_data_alloc(
int type) {
83 __DATA.record(type, std::clock() - __allocation_time);
Definition: alloc_monitor.h:70
Definition: alloc_monitor.h:30