AndroidViewClient's device.touch() is much slower than MonkeyRunner's. Can it be fixed?

老子叫甜甜 提交于 2019-12-04 12:47:43

You're absolutely correct, if you look at the codes of AVC and MonkeyRunner, I think the flow chart is like below, both are using sockets but the difference of speed is because Monkeyrunner uses direct client socket to connect to Monkey server on the device to send command like tap, press once the monkey server is started on the device. AVC socket communicates to adb server to send the input tap/press, I don't know which "sauce" is in adb input, I guess it is Java which produce this slow response time. I think the owner of AVC can implement the Monkey server in a blink of eyes, but there is a problem, Uiautomator and Monkey can not coexist together, so I guess he should make a tradeoff between speed and stability for the majority of users:

AVC: client socket ---> ADB server ---> ADB daemon on device
MonkeyRunner: client socket ---> Monkey server on device

One quick workaround you can try is

cmd = ''
for _ in range(6):
    cmd += 'input tap 1 1;'
ts_start = datetime.datetime.now()
device.shell(cmd)
chrono = datetime.datetime.now() - ts_start
print str(chrono)

it may help you but may not be suitable for all the cases.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!