1 # SPDX-FileCopyrightText: 2017-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
9 # print('psutil available')
10 psutil_available
= True
12 psutil_available
= False
17 self
.memstats_available
= False
19 self
.process
= psutil
.Process()
20 self
.memstats_available
= True
24 self
.lasttime
= self
._gettime
()
25 self
.lastmem
= self
._getmem
()
26 self
.basemem
= self
.lastmem
31 """return the time in seconds used by the current process."""
33 """ Handle psutil API change. """
34 if hasattr(self
.process
, "get_cpu_times"):
35 m
= self
.process
.get_cpu_times()
37 m
= self
.process
.cpu_times()
38 return m
.user
+ m
.system
42 """return the resident set size in bytes used by the current process."""
44 """ Handle psutil API change. """
45 if hasattr(self
.process
, "get_memory_info"):
46 m
= self
.process
.get_memory_info()
48 m
= self
.process
.memory_info()
53 """return the time since the last call in seconds used by the current process."""
55 self
.lasttime
= self
._gettime
()
56 self
.elapsedtime
= self
.lasttime
- old
57 return self
.elapsedtime
60 """return the maximum resident set size since the first call in bytes used by the current process."""
61 self
.lastmem
= self
._getmem
()
62 d
= self
.lastmem
- self
.basemem