psutils, how to correctly calculate a process CPU utilization
Most likely due to the 3% being total usage over all cores while 25% is usage of a single core capacity. You can always look at the documentation of psutil.cpu_percent()
and psutil.Process.cpu_percent()
to get some more in-depth explanation of the behaviour.
To get the usage of total system capacity you need to divide it by the number of CPUs you got access to:
PID = 1245
p = psutil.Process(PID)
tot_load_from_process = p.cpu_percent()/psutil.cpu_count()
print(tot_load_from_process)
print(psutil.cpu_pecent())