4

I use library JavaSysMon to get processes name list but the class ProcessInfo has methods getResidentBytes(), getSystemMillis().

How to calculate cpu usage for process ?

Seki
  • 11,135
  • 7
  • 46
  • 70
nop mface
  • 41
  • 4
  • What do you mean by "how to calculate"? These two methods return the respective metrics as a number. – Thilo Apr 27 '15 at 03:57
  • It method getResidentBytes() and getSystemMillis() isn't involve calculate ? – nop mface Apr 27 '15 at 04:11
  • did you mean the list of processes `Process p = Runtime.getRuntime().exec("ps -a");` – Vinayak Pingale Apr 27 '15 at 04:11
  • Yes @ Vinayak Pingale but Runtime.getRuntime().exec("ps -a") work on linux – nop mface Apr 27 '15 at 04:16
  • I doubt that the two methods calculate anything. They will just pass on the information that the OS has about the process in question. – Thilo Apr 27 '15 at 04:38
  • Fixed the link and code markup – Seki Apr 29 '15 at 15:13
  • Take a look at [java cpu usage monitoring](http://stackoverflow.com/q/2062440/113632), particularly [this answer](http://stackoverflow.com/a/14712892/113632) which demonstrates how to calculate CPU usage. – dimo414 Jun 13 '15 at 17:01

0 Answers0