ATLAS Offline Software
ArenaAllocatorBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id: ArenaAllocatorBase.cxx 470529 2011-11-24 23:54:22Z ssnyder $
15 #include <ostream>
16 #include <iomanip>
17 
18 
19 namespace SG {
20 
21 
26  : inuse (0),
27  free (0),
28  total (0)
29 {
30 }
31 
32 
37 {
38  inuse = free = total = 0;
39 }
40 
41 
48 {
49  inuse += other.inuse;
50  free += other.free;
51  total += other.total;
52  return *this;
53 }
54 
55 
56 /* (hide from doxygen)
57  * @brief Format a statistic structure.
58  * @param os The stream to which to write.
59  * @param stat The statistic structure to write.
60  */
61 std::ostream& operator<< (std::ostream& os,
63 {
64  os << std::setw(7) << stat.inuse << "/"
65  << std::setw(7) << stat.free << "/"
66  << std::setw(7) << stat.total;
67  return os;
68 }
69 
70 
71 //===========================================================================
72 
73 
78 {
79  elts.clear();
80  bytes.clear();
81  blocks.clear();
82 }
83 
84 
91 {
92  elts += other.elts;
93  bytes += other.bytes;
94  blocks += other.blocks;
95  return *this;
96 }
97 
98 
99 /* (hide from doxygen)
100  * @brief Format a complete statistics structure.
101  * @param os The stream to which to write.
102  * @param stats The statistics structure to write.
103  */
104 std::ostream& operator<< (std::ostream& os,
106 {
107  os << stats.elts << " " << stats.bytes << " " << stats.blocks;
108  return os;
109 }
110 
111 
117 {
118  os << "Elts InUse/Free/Total"
119  << " Bytes InUse/Free/Total Blocks InUse/Free/Total";
120 }
121 
122 
123 //===========================================================================
124 
125 
130 void ArenaAllocatorBase::report (std::ostream& os) const
131 {
132  os << " " << stats() << " " << name() << std::endl;
133 }
134 
135 
136 } // namespace SG
SG::ArenaAllocatorBase::stats
virtual Stats stats() const =0
Return the statistics block for this allocator.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ArenaAllocatorBase::Stats::blocks
Stat blocks
Counts of blocks.
Definition: ArenaAllocatorBase.h:217
SG::ArenaAllocatorBase::Stats::Stat::clear
void clear()
Reset to zero.
Definition: ArenaAllocatorBase.cxx:36
SG::ArenaAllocatorBase::Stats::Stat
A single statistic.
Definition: ArenaAllocatorBase.h:193
SG::ArenaAllocatorBase::Stats::clear
void clear()
Reset to zero.
Definition: ArenaAllocatorBase.cxx:77
SG::ArenaAllocatorBase::Stats
Statistics for an allocator.
Definition: ArenaAllocatorBase.h:188
SG::ArenaAllocatorBase::Stats::Stat::operator+=
Stat & operator+=(const Stat &other)
Accumulate.
Definition: ArenaAllocatorBase.cxx:47
ArenaAllocatorBase.h
Common base class for arena allocator classes. See Arena.h for an overview of the arena-based memory ...
SG::ArenaAllocatorBase::report
virtual void report(std::ostream &os) const
Generate a report on the memory usage of this allocator.
Definition: ArenaAllocatorBase.cxx:130
beamspotman.stat
stat
Definition: beamspotman.py:266
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SG::ArenaAllocatorBase::Stats::bytes
Stat bytes
Counts of bytes.
Definition: ArenaAllocatorBase.h:221
SG::ArenaAllocatorBase::Stats::Stat::Stat
Stat()
Default constructor.
Definition: ArenaAllocatorBase.cxx:25
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::ArenaAllocatorBase::Stats::header
static void header(std::ostream &os)
Print report header.
Definition: ArenaAllocatorBase.cxx:116
SG::operator<<
std::ostream & operator<<(std::ostream &os, const ArenaAllocatorBase::Stats::Stat &stat)
Format a statistic structure.
Definition: ArenaAllocatorBase.cxx:61
SG::ArenaAllocatorBase::Stats::operator+=
Stats & operator+=(const Stats &other)
Accumulate.
Definition: ArenaAllocatorBase.cxx:90
SG::ArenaAllocatorBase::Stats::elts
Stat elts
Counts of elements.
Definition: ArenaAllocatorBase.h:219
SG::ArenaAllocatorBase::name
virtual const std::string & name() const =0
Return the name of this allocator.