Take the 2-minute tour ×

I want to get cpu usage of the phone and then draw on PC.

I want to do like this:

First, run a background process in the phone which caculate the CPU usage and show in terminal.

Second, use adb commnad to get the terminal output.

Finally, draw curve with data.

I'm confused wheather it will work normally without big latency. At first, I want to put the cpu usage into a file, and use command of 'adb pull' to pull the file, then read the file and draw. I thought this may cause big latency.

Does anyone could help me?

Thanks. James.

share|improve this question

2 Answers 2

I'm not entirely sure if that is what you are trying to achieve but you can use:

  1. adb shell to access the shell prompt of the device and run commands from there. See: http://developer.android.com/tools/help/adb.html#shellcommands

  2. adb logcat to get the live log stream from the device. You can use filters etc to adjust the output to what you need. See: http://developer.android.com/tools/help/adb.html#logcat

share|improve this answer
  1. Write an Android application write to a file, for sample: cpu_usage.txt

  2. Use LogCat to get output: adb shell cat /path_to_your_file/cpu_usage.txt

Parse the output from command line, then draw it on the graph. High latency? Nope.

Edit: Ok, if you get root permission, just execute the command as you wish, for example,

C:\>adb shell top -m -d 1 -n 1 > C:\top_result.txt

Check out the result at: C:\top_result.txt. Also, as I read your message, you say something like socket, if I were you, I would never use it, because it always causes high latency.

share|improve this answer
Write an application may be inconvenient. Because I can get the root, so now I write an executable file which calc the cpu-usage into /system/bin/, then use adb socket to get the results. Is there anyway to use adb socket get result? –  james Aug 20 '12 at 8:07
I've updated my answer! –  xjaphx Aug 20 '12 at 11:56
"adb shell" isn't LogCat, they are two different things: developer.android.com/tools/help/adb.html –  Johan Walles Jun 18 '13 at 9:42

Your Answer


