Suppose we want to find out how much energy, CPU and RAM are being used in Python to find out the factorial of a positive integer. I used the code below but it is not working.
MWE:
from __future__ import print_function
import psutil
n=5
fact=1
for i in range(1,n+1):
fact=fact*i
print fact
print('CPU % used:', psutil.cpu_percent())
print('physical memory % used:', psutil.virtual_memory()) # physical memory usage
print('memory % used:', psutil.virtual_memory()[2])