[android-developers] Re: Obtaining/calculating process CPU usage.
On Thu, May 7, 2009 at 7:34 AM, Sachin pandhare wrote: > > Hello Dianne, > Which functionality may break in future releases? > Is it executing the command using runtime? > "String cmd = "top -n 1"; > process = runtime.exec(cmd);" > the format, or even the availability of "top" is very likely to change in future updates. > > or something else in this code segment? > thanks, > Sachin > > On May 5, 9:44 pm, Dianne Hackborn wrote: > > This is very likely to break in future platform updates. > > > > > > > > On Tue, May 5, 2009 at 7:53 AM, rezar wrote: > > > > > You can use output of the top command, for your process > > > Here is what I did: > > > > >Runtime runtime = Runtime.getRuntime(); > > >Process process; > > >String res = "-0-"; > > >try { > > >String cmd = "top -n 1"; > > >process = runtime.exec(cmd); > > >InputStream is = process.getInputStream(); > > >InputStreamReader isr = new > InputStreamReader(is); > > >BufferedReader br = new BufferedReader(isr); > > >String line ; > > >while ((line = br.readLine()) != null) { > > >String segs[] = line.trim().split("[ > ]+"); > > >if (segs[0].equalsIgnoreCase([Your > Process > > > ID])) { > > >res = segs[1]; > > >break; > > >} > > >} > > >} catch (Exception e) { > > >e.fillInStackTrace(); > > >Log.e("Process Manager", "Unable to execute top > > > command"); > > > } > > > > > On May 4, 4:02 pm, Donald_W wrote: > > > > Hello, > > > > > > How can I get/calculate current process CPU usage? ActivityManager > > > > provides method that returns a list of all active processes (list of > > > > RunningAppProcessInfo), but that class doesn't provide any CPU usage > > > > information. > > > > > > Thanks in advance, > > > > Tomek > > > > -- > > Dianne Hackborn > > Android framework engineer > > hack...@android.com > > > > Note: please don't send private questions to me, as I don't have time to > > provide private support, and so won't reply to such e-mails. All such > > questions should be posted on public forums, where I and others can see > and > > answer them. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Obtaining/calculating process CPU usage.
Hello Dianne, Which functionality may break in future releases? Is it executing the command using runtime? "String cmd = "top -n 1"; process = runtime.exec(cmd);" or something else in this code segment? thanks, Sachin On May 5, 9:44 pm, Dianne Hackborn wrote: > This is very likely to break in future platform updates. > > > > On Tue, May 5, 2009 at 7:53 AM, rezar wrote: > > > You can use output of the top command, for your process > > Here is what I did: > > > Runtime runtime = Runtime.getRuntime(); > > Process process; > > String res = "-0-"; > > try { > > String cmd = "top -n 1"; > > process = runtime.exec(cmd); > > InputStream is = process.getInputStream(); > > InputStreamReader isr = new InputStreamReader(is); > > BufferedReader br = new BufferedReader(isr); > > String line ; > > while ((line = br.readLine()) != null) { > > String segs[] = line.trim().split("[ ]+"); > > if (segs[0].equalsIgnoreCase([Your Process > > ID])) { > > res = segs[1]; > > break; > > } > > } > > } catch (Exception e) { > > e.fillInStackTrace(); > > Log.e("Process Manager", "Unable to execute top > > command"); > > } > > > On May 4, 4:02 pm, Donald_W wrote: > > > Hello, > > > > How can I get/calculate current process CPU usage? ActivityManager > > > provides method that returns a list of all active processes (list of > > > RunningAppProcessInfo), but that class doesn't provide any CPU usage > > > information. > > > > Thanks in advance, > > > Tomek > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Obtaining/calculating process CPU usage.
This is very likely to break in future platform updates. On Tue, May 5, 2009 at 7:53 AM, rezar wrote: > > You can use output of the top command, for your process > Here is what I did: > >Runtime runtime = Runtime.getRuntime(); >Process process; >String res = "-0-"; >try { >String cmd = "top -n 1"; >process = runtime.exec(cmd); >InputStream is = process.getInputStream(); >InputStreamReader isr = new InputStreamReader(is); >BufferedReader br = new BufferedReader(isr); >String line ; >while ((line = br.readLine()) != null) { >String segs[] = line.trim().split("[ ]+"); >if (segs[0].equalsIgnoreCase([Your Process > ID])) { >res = segs[1]; >break; >} >} >} catch (Exception e) { >e.fillInStackTrace(); >Log.e("Process Manager", "Unable to execute top > command"); > } > > On May 4, 4:02 pm, Donald_W wrote: > > Hello, > > > > How can I get/calculate current process CPU usage? ActivityManager > > provides method that returns a list of all active processes (list of > > RunningAppProcessInfo), but that class doesn't provide any CPU usage > > information. > > > > Thanks in advance, > > Tomek > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Obtaining/calculating process CPU usage.
I though I sent it once, but Use out put of top linux command with java Runtime. On May 4, 4:02 pm, Donald_W wrote: > Hello, > > How can I get/calculate current process CPU usage? ActivityManager > provides method that returns a list of all active processes (list of > RunningAppProcessInfo), but that class doesn't provide any CPU usage > information. > > Thanks in advance, > Tomek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Obtaining/calculating process CPU usage.
You can use output of the top command, for your process Here is what I did: Runtime runtime = Runtime.getRuntime(); Process process; String res = "-0-"; try { String cmd = "top -n 1"; process = runtime.exec(cmd); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line ; while ((line = br.readLine()) != null) { String segs[] = line.trim().split("[ ]+"); if (segs[0].equalsIgnoreCase([Your Process ID])) { res = segs[1]; break; } } } catch (Exception e) { e.fillInStackTrace(); Log.e("Process Manager", "Unable to execute top command"); } On May 4, 4:02 pm, Donald_W wrote: > Hello, > > How can I get/calculate current process CPU usage? ActivityManager > provides method that returns a list of all active processes (list of > RunningAppProcessInfo), but that class doesn't provide any CPU usage > information. > > Thanks in advance, > Tomek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Obtaining/calculating process CPU usage.
Well I thought rather of any calculations using some process data. Anyway thanks for help. BR, Tomek On May 5, 9:20 am, Dianne Hackborn wrote: > There is no supported API for this. I am not helping people find and use > unsupported APIs, and then having to deal with their apps breaking when we > update the platform. > > > > On Mon, May 4, 2009 at 11:43 PM, Donald_W wrote: > > > So is there any possibility to calculate CPU usage? > > > On May 4, 9:19 pm, Dianne Hackborn wrote: > > > There isn't a supported API for this. > > > > On Mon, May 4, 2009 at 7:02 AM, Donald_W wrote: > > > > > Hello, > > > > > How can I get/calculate current process CPU usage? ActivityManager > > > > provides method that returns a list of all active processes (list of > > > > RunningAppProcessInfo), but that class doesn't provide any CPU usage > > > > information. > > > > > Thanks in advance, > > > > Tomek > > > > -- > > > Dianne Hackborn > > > Android framework engineer > > > hack...@android.com > > > > Note: please don't send private questions to me, as I don't have time to > > > provide private support, and so won't reply to such e-mails. All such > > > questions should be posted on public forums, where I and others can see > > and > > > answer them. > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Obtaining/calculating process CPU usage.
There is no supported API for this. I am not helping people find and use unsupported APIs, and then having to deal with their apps breaking when we update the platform. On Mon, May 4, 2009 at 11:43 PM, Donald_W wrote: > > So is there any possibility to calculate CPU usage? > > On May 4, 9:19 pm, Dianne Hackborn wrote: > > There isn't a supported API for this. > > > > On Mon, May 4, 2009 at 7:02 AM, Donald_W wrote: > > > > > Hello, > > > > > How can I get/calculate current process CPU usage? ActivityManager > > > provides method that returns a list of all active processes (list of > > > RunningAppProcessInfo), but that class doesn't provide any CPU usage > > > information. > > > > > Thanks in advance, > > > Tomek > > > > -- > > Dianne Hackborn > > Android framework engineer > > hack...@android.com > > > > Note: please don't send private questions to me, as I don't have time to > > provide private support, and so won't reply to such e-mails. All such > > questions should be posted on public forums, where I and others can see > and > > answer them. > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Obtaining/calculating process CPU usage.
So is there any possibility to calculate CPU usage? On May 4, 9:19 pm, Dianne Hackborn wrote: > There isn't a supported API for this. > > On Mon, May 4, 2009 at 7:02 AM, Donald_W wrote: > > > Hello, > > > How can I get/calculate current process CPU usage? ActivityManager > > provides method that returns a list of all active processes (list of > > RunningAppProcessInfo), but that class doesn't provide any CPU usage > > information. > > > Thanks in advance, > > Tomek > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Obtaining/calculating process CPU usage.
There isn't a supported API for this. On Mon, May 4, 2009 at 7:02 AM, Donald_W wrote: > > Hello, > > How can I get/calculate current process CPU usage? ActivityManager > provides method that returns a list of all active processes (list of > RunningAppProcessInfo), but that class doesn't provide any CPU usage > information. > > Thanks in advance, > Tomek > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---