ATLAS Offline Software
Loading...
Searching...
No Matches
Database
CoolRunQuery
python
utils
AtlRunQueryMemUtil.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3
import
os
4
5
_proc_status =
'/proc/%d/status'
% os.getpid()
6
7
_scale = {
'kB'
: 1024.0,
'mB'
: 1024.0*1024.0,
8
'KB'
: 1024.0,
'MB'
: 1024.0*1024.0}
9
10
def
_VmB
(VmKey):
11
'''Private.
12
'''
13
# get pseudo file /proc/<pid>/status
14
try
:
15
t = open(_proc_status)
16
v = t.read()
17
t.close()
18
except
(OSError,ValueError):
19
return
0.0
# non-Linux?
20
# get VmKey line e.g. 'VmRSS: 9999 kB\n ...'
21
i = v.index(VmKey)
22
v = v[i:].
split
(
None
, 3)
# whitespace
23
if
len(v) < 3:
24
return
0.0
# invalid format?
25
# convert Vm value to bytes
26
return
float(v[1]) * _scale[v[2]]
27
28
29
def
memory
(since=0.0):
30
'''Return memory usage in bytes.
31
'''
32
return
_VmB
(
'VmSize:'
) - since
33
34
35
def
resident
(since=0.0):
36
'''Return resident memory usage in bytes.
37
'''
38
return
_VmB
(
'VmRSS:'
) - since
39
40
41
def
stacksize
(since=0.0):
42
'''Return stack size in bytes.
43
'''
44
return
_VmB
(
'VmStk:'
) - since
split
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition
hcg.cxx:177
python.utils.AtlRunQueryMemUtil.stacksize
stacksize(since=0.0)
Definition
AtlRunQueryMemUtil.py:41
python.utils.AtlRunQueryMemUtil._VmB
_VmB(VmKey)
Definition
AtlRunQueryMemUtil.py:10
python.utils.AtlRunQueryMemUtil.resident
resident(since=0.0)
Definition
AtlRunQueryMemUtil.py:35
python.utils.AtlRunQueryMemUtil.memory
memory(since=0.0)
Definition
AtlRunQueryMemUtil.py:29
Generated on
for ATLAS Offline Software by
1.14.0