I've been searching this for quite a long time and I found no proper answer to this.
It should be something quite simple to do with a library which is suppose to help you in this matter, but it seems it is not that simple.
I found an answer in stackoverflow which suggest a way to do it.
I've tried to apply that to my own code and it seems to work almost ok despite the fact that sometimes I get negative values (so I added a Math.abs) and now I'm getting also sometimes values over 100%, like 5000 for example.
Any idea why this implementation is not working? I've no idea to which value I have to set the variable TOTAL_TIME_UPDATE_LIMIT
named in the answer, could it be the reason?
If so, how do you deal with calculating the CPU for a process?
Thanks.