ATLAS Offline Software
Loading...
Searching...
No Matches
CoWTools::CoWRecordStats Class Reference

#include <CoWRecordStats.h>

Collaboration diagram for CoWTools::CoWRecordStats:

Public Types

enum  ValueIdx {
  Size =0 , Rss =1 , Pss =2 , Shared_Clean =3 ,
  Shared_Dirty =4 , Private_Clean =5 , Private_Dirty =6 , Referenced =7 ,
  Anonymous =8 , AnonHugePages =9 , Swap =10 , KernelPageSize =11 ,
  MMUPageSize =12 , Locked =13 , VmFlags =14
}

Public Member Functions

 CoWRecordStats (bool summary=true)
CoWRecordStatsoperator+= (const CoWRecordStats &rhs)
CoWRecordStatsoperator-= (const CoWRecordStats &rhs)
CoWRecordStats operator- () const
 operator bool () const
void parseRecord (std::istream &in)
long long * getValueArray ()
const long long * getValueArray () const

Private Attributes

long long m_vals [20]
bool m_summary

Static Private Attributes

static const std::map< std::string, int > s_vmFlags

Friends

CoWRecordStats operator+ (const CoWRecordStats &lhs, const CoWRecordStats &rhs)
CoWRecordStats operator- (const CoWRecordStats &lhs, const CoWRecordStats &rhs)
bool operator< (const CoWRecordStats &a, const CoWRecordStats &b)
std::ostream & operator<< (std::ostream &out, const CoWTools::CoWRecordStats &m)

Detailed Description

Definition at line 13 of file CoWRecordStats.h.

Member Enumeration Documentation

◆ ValueIdx

Enumerator
Size 
Rss 
Pss 
Shared_Clean 
Shared_Dirty 
Private_Clean 
Private_Dirty 
Referenced 
Anonymous 
AnonHugePages 
Swap 
KernelPageSize 
MMUPageSize 
Locked 
VmFlags 

Definition at line 16 of file CoWRecordStats.h.

Constructor & Destructor Documentation

◆ CoWRecordStats()

CoWTools::CoWRecordStats::CoWRecordStats ( bool summary = true)
inline

Definition at line 15 of file CoWRecordStats.h.

15:m_summary(summary){};

Member Function Documentation

◆ getValueArray() [1/2]

long long * CoWTools::CoWRecordStats::getValueArray ( )
inline

Definition at line 94 of file CoWRecordStats.h.

94{return m_vals;}

◆ getValueArray() [2/2]

const long long * CoWTools::CoWRecordStats::getValueArray ( ) const
inline

Definition at line 95 of file CoWRecordStats.h.

95{return m_vals;}

◆ operator bool()

CoWTools::CoWRecordStats::operator bool ( ) const
inlineexplicit

Definition at line 74 of file CoWRecordStats.h.

74 {
75 for(int i=0;i<11;i++){
76 if(m_vals[i])return true;
77 }
78 return false;
79 }

◆ operator+=()

CoWRecordStats & CoWTools::CoWRecordStats::operator+= ( const CoWRecordStats & rhs)
inline

Definition at line 35 of file CoWRecordStats.h.

35 {
36 for(int i=0;i<11;i++){
37 m_vals[i]+=rhs.m_vals[i];
38 }
39 m_vals[13]+=rhs.m_vals[13];
40 //needed only for very detailed
41 //m_vals[14]|=rhs.m_vals[14];
42 return *this;
43 }

◆ operator-()

CoWRecordStats CoWTools::CoWRecordStats::operator- ( ) const
inline

Definition at line 55 of file CoWRecordStats.h.

55 {
57 for(int i=0;i<11;i++){
58 m.m_vals[i]=-m_vals[i];
59 }
60 m.m_vals[11]=m_vals[11];
61 m.m_vals[12]=m_vals[12];
62 m.m_vals[13]=-m_vals[13];
63 m.m_vals[14]=m_vals[14];
64 //needed only for very detailed
65 //m_vals[14]|=rhs.m_vals[14];
66 return m;
67 }
CoWRecordStats(bool summary=true)

◆ operator-=()

CoWRecordStats & CoWTools::CoWRecordStats::operator-= ( const CoWRecordStats & rhs)
inline

Definition at line 45 of file CoWRecordStats.h.

45 {
46 for(int i=0;i<11;i++){
47 m_vals[i]-=rhs.m_vals[i];
48 }
49 m_vals[13]-=rhs.m_vals[13];
50 //needed only for very detailed
51 //m_vals[14]|=rhs.m_vals[14];
52 return *this;
53 }

◆ parseRecord()

void CoWTools::CoWRecordStats::parseRecord ( std::istream & in)

Definition at line 40 of file CoWRecordStats.cxx.

40 {
41 std::string line;
42 int pos=0;
43 //std::cout<<"in MS"<<std::endl;
44 while(!(std::getline(in,line).eof())){
45 //std::cout<<"MS "<<line<<std::endl;
46 int len=0;
47 unsigned long val=0;
48 char buff[20];
49 sscanf(line.c_str(),"%19s%n",buff,&len);
50 if(strcmp(buff,"VmFlags:")==0){
51 len++;
52 while(len<(int)line.size()){
53 //std::cerr<<"substr="<<line.substr(len,2)<<std::endl;
55 len+=3;
56 }
57 }else{
58 sscanf(line.c_str()+len,"%8lu",&val);
59 }
60 m_vals[pos]=val;
61 pos++;
62 }
63}
static const std::map< std::string, int > s_vmFlags

◆ operator+

CoWRecordStats operator+ ( const CoWRecordStats & lhs,
const CoWRecordStats & rhs )
friend

Definition at line 68 of file CoWRecordStats.h.

68 {
69 return CoWRecordStats(lhs) += rhs;
70 }

◆ operator-

CoWRecordStats operator- ( const CoWRecordStats & lhs,
const CoWRecordStats & rhs )
friend

Definition at line 71 of file CoWRecordStats.h.

71 {
72 return CoWRecordStats(lhs) -= rhs;
73 }

◆ operator<

bool operator< ( const CoWRecordStats & a,
const CoWRecordStats & b )
friend

Definition at line 80 of file CoWRecordStats.h.

80 {
81 if((a.m_vals[5]+a.m_vals[6])<(b.m_vals[5]+b.m_vals[6])){
82 return true;
83 }else if((a.m_vals[5]+a.m_vals[6])==(b.m_vals[5]+b.m_vals[6])){
84 if((a.m_vals[3]+a.m_vals[4])<(b.m_vals[3]+b.m_vals[4])){
85 return true;
86 }else if((a.m_vals[3]+a.m_vals[4])==(b.m_vals[3]+b.m_vals[4])){
87 return (a.m_vals[1]<b.m_vals[1]);
88 }
89 return false;
90 }
91 return false;
92 }
static Double_t a

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const CoWTools::CoWRecordStats & m )
friend

Definition at line 67 of file CoWRecordStats.cxx.

67 {
68 if(m.m_summary){
69 char buff[2048];
70 snprintf(buff,2048,"VMem= %8lld, RSS= %8lld, PSS= %8lld, Shared= %8lld, Private= %8lld, Swap= %8lld Anon= %8lld",
71 m.m_vals[0],m.m_vals[1],m.m_vals[2],m.m_vals[3]+m.m_vals[4],m.m_vals[5]+m.m_vals[6],m.m_vals[10],m.m_vals[8]);
72 out<<buff;
73 }else{
74 char buff[4000];
75 snprintf(buff,4000,
76 "Size: %8lld kB\n" \
77 "Rss: %8lld kB\n" \
78 "Pss: %8lld kB\n" \
79 "Shared_Clean: %8lld kB\n" \
80 "Shared_Dirty: %8lld kB\n" \
81 "Private_Clean: %8lld kB\n" \
82 "Private_Dirty: %8lld kB\n" \
83 "Referenced: %8lld kB\n" \
84 "Anonymous: %8lld kB\n" \
85 "AnonHugePages: %8lld kB\n" \
86 "Swap: %8lld kB\n" \
87 "KernelPageSize: %8lld kB\n" \
88 "MMUPageSize: %8lld kB\n" \
89 "Locked: %8lld kB\n",
90 m.m_vals[0],
91 m.m_vals[1],
92 m.m_vals[2],
93 m.m_vals[3],
94 m.m_vals[4],
95 m.m_vals[5],
96 m.m_vals[6],
97 m.m_vals[7],
98 m.m_vals[8],
99 m.m_vals[9],
100 m.m_vals[10],
101 m.m_vals[11],
102 m.m_vals[12],
103 m.m_vals[13]);
104 out<<buff;
105 }
106 return out;
107 }

Member Data Documentation

◆ m_summary

bool CoWTools::CoWRecordStats::m_summary
private

Definition at line 102 of file CoWRecordStats.h.

◆ m_vals

long long CoWTools::CoWRecordStats::m_vals[20]
private
Initial value:
={0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0}

Definition at line 97 of file CoWRecordStats.h.

97 {0,0,0,0,0,
98 0,0,0,0,0,
99 0,0,0,0,0,
100 0,0,0,0,0};

◆ s_vmFlags

const std::map< std::string, int > CoWTools::CoWRecordStats::s_vmFlags
staticprivate
Initial value:
={
{"rd",0x00000001},
{"wr",0x00000002},
{"ex",0x00000004},
{"sh",0x00000008},
{"mr",0x00000010},
{"mw",0x00000020},
{"me",0x00000040},
{"ms",0x00000060},
{"gd",0x00000080},
{"pf",0x00000100},
{"dw",0x00000200},
{"lo",0x00000400},
{"io",0x00000800},
{"sr",0x00001000},
{"rr",0x00002000},
{"dc",0x00004000},
{"de",0x00008000},
{"ac",0x00010000},
{"nr",0x00020000},
{"ht",0x00040000},
{"nl",0x00080000},
{"ar",0x00100000},
{"dd",0x00200000},
{"sd",0x00400000},
{"mm",0x00800000},
{"hg",0x01000000},
{"nh",0x02000000},
{"mg",0x04000000}
}

Definition at line 9 of file CoWRecordStats.h.

12 {
13 class CoWRecordStats{
14 public:
15 CoWRecordStats(bool summary=true):m_summary(summary){};
16 enum ValueIdx{
17 Size=0,
18 Rss=1,
19 Pss=2,
24 Referenced=7,
25 Anonymous=8,
27 Swap=10,
29 MMUPageSize=12,
30 Locked=13,
31 VmFlags=14
32 };
33
34
35 inline CoWRecordStats& operator+=(const CoWRecordStats& rhs){
36 for(int i=0;i<11;i++){
37 m_vals[i]+=rhs.m_vals[i];
38 }
CoWRecordStats & operator+=(const CoWRecordStats &rhs)

The documentation for this class was generated from the following files: