python system performance 1

python system performance

import os
import psutil
pid = os.getpid()
py = psutil.Process(pid)
memoryUse = py.memory_info()[0]/2.**30  # memory use in GB...I think
print('memory use:', memoryUse)

Here is what the above code is Doing:
1. Import the os and psutil modules.
2. Get the current process id.
3. Create a process object.
4. Get the memory use in GB.
5. Print the memory use.

Similar Posts