1 # SPDX-License-Identifier: GPL-2.0-or-later
7 # print('psutil available')
8 psutil_available
= True
10 psutil_available
= False
15 self
.memstats_available
= False
17 self
.process
= psutil
.Process()
18 self
.memstats_available
= True
22 self
.lasttime
= self
._gettime
()
23 self
.lastmem
= self
._getmem
()
24 self
.basemem
= self
.lastmem
29 """return the time in seconds used by the current process."""
31 """ Handle psutil API change. """
32 if hasattr(self
.process
, "get_cpu_times"):
33 m
= self
.process
.get_cpu_times()
35 m
= self
.process
.cpu_times()
36 return m
.user
+ m
.system
40 """return the resident set size in bytes used by the current process."""
42 """ Handle psutil API change. """
43 if hasattr(self
.process
, "get_memory_info"):
44 m
= self
.process
.get_memory_info()
46 m
= self
.process
.memory_info()
51 """return the time since the last call in seconds used by the current process."""
53 self
.lasttime
= self
._gettime
()
54 self
.elapsedtime
= self
.lasttime
- old
55 return self
.elapsedtime
58 """return the maximum resident set size since the first call in bytes used by the current process."""
59 self
.lastmem
= self
._getmem
()
60 d
= self
.lastmem
- self
.basemem