0

I am using a monkeyrunner Jython script to automate some UI test. I want to confirm that the previous step is complete before doing the next step, based on the current CPU usage of the OS (of the PC the emulator is running on). Hence I need a way to get current CPU usage in a monkeyrunner Jython script.

I've done some survey, but looks like monkeyrunner Jython script does not work with psutil: Monkeyrunner doesnt find my module

Anyone could tell me what is the easiest way to get current CPU usage in a monkeyrunner Jython script?

Thanks.

Community
  • 1
  • 1
Jiechao Wang
  • 922
  • 1
  • 15
  • 32

2 Answers2

0

try top command to get cpu usage,

1.try this if you want to get cpu usage of android device:-

import os
top_10_ps_list=os.popen('adb shell top -n 1 -m 10').read()

2.try this if you want to get cpu usage of PC OS:-

import os
top_10_ps_list=os.popen('top -b -n 1').read()
Rilwan
  • 2,251
  • 2
  • 19
  • 28
0

You can invoke shell commands directly from MonkeyDevice:

top10 = device.shell('top -n 1 -m 10')
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134