ATLAS Offline Software
Loading...
Searching...
No Matches
Control
CoWTools
src
CoWRecordStats.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CoWTools/CoWRecordStats.h
"
6
#include <cstring>
7
#include <cstdio>
8
9
const
std::map<std::string,int>
CoWTools::CoWRecordStats::s_vmFlags
={
10
{
"rd"
,0x00000001},
11
{
"wr"
,0x00000002},
12
{
"ex"
,0x00000004},
13
{
"sh"
,0x00000008},
14
{
"mr"
,0x00000010},
15
{
"mw"
,0x00000020},
16
{
"me"
,0x00000040},
17
{
"ms"
,0x00000060},
18
{
"gd"
,0x00000080},
19
{
"pf"
,0x00000100},
20
{
"dw"
,0x00000200},
21
{
"lo"
,0x00000400},
22
{
"io"
,0x00000800},
23
{
"sr"
,0x00001000},
24
{
"rr"
,0x00002000},
25
{
"dc"
,0x00004000},
26
{
"de"
,0x00008000},
27
{
"ac"
,0x00010000},
28
{
"nr"
,0x00020000},
29
{
"ht"
,0x00040000},
30
{
"nl"
,0x00080000},
31
{
"ar"
,0x00100000},
32
{
"dd"
,0x00200000},
33
{
"sd"
,0x00400000},
34
{
"mm"
,0x00800000},
35
{
"hg"
,0x01000000},
36
{
"nh"
,0x02000000},
37
{
"mg"
,0x04000000}
38
};
39
40
void
CoWTools::CoWRecordStats::parseRecord
(std::istream &in){
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;
54
val|=
CoWTools::CoWRecordStats::s_vmFlags
.at(line.substr(len,2));
55
len+=3;
56
}
57
}
else
{
58
sscanf(line.c_str()+len,
"%8lu"
,&val);
59
}
60
m_vals
[pos]=val;
61
pos++;
62
}
63
}
64
65
namespace
CoWTools
{
66
67
std::ostream &
operator<<
(std::ostream &out,
const
CoWRecordStats
&m){
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
}
108
}
109
CoWRecordStats.h
CoWTools::CoWRecordStats::s_vmFlags
static const std::map< std::string, int > s_vmFlags
Definition
CoWRecordStats.h:9
CoWTools::CoWRecordStats::parseRecord
void parseRecord(std::istream &in)
Definition
CoWRecordStats.cxx:40
CoWTools::CoWRecordStats::m_vals
long long m_vals[20]
Definition
CoWRecordStats.h:97
CoWTools::CoWRecordStats::CoWRecordStats
CoWRecordStats(bool summary=true)
Definition
CoWRecordStats.h:15
CoWTools
Definition
CoWLibrary.h:15
CoWTools::operator<<
std::ostream & operator<<(std::ostream &os, const CoWTools::CoWLibrary &l)
Definition
CoWLibrary.cxx:54
Generated on
for ATLAS Offline Software by
1.14.0