AndroidViewClient的device.touch()比MonkeyRunner的要慢得多。是否可以解决吗? [英] AndroidViewClient's device.touch() is much slower than MonkeyRunner's. Can it be fixed?

查看:1537
本文介绍了AndroidViewClient的device.touch()比MonkeyRunner的要慢得多。是否可以解决吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经抛弃MonkeyRunner为AndroidViewClient从其提高可靠性和实施的简便受益(感谢上帝纯Python)。

I've ditched MonkeyRunner for AndroidViewClient to benefit from its added reliability and simplicity of implementation (thank God for pure Python).

我需要尽可能快地执行多个device.touch()事件,但是AndroidViewClient似乎实现这些比MonkeyRunner显著慢。

I need to perform several device.touch() events as fast as possible, however AndroidViewClient seems to achieve those significantly slower than MonkeyRunner.

这里的code口用于定时他们两个:

Here's the code I used to time them both:

for iteration in range(1,6):
    ts_start = datetime.datetime.now()
    device.touch(1,1,'DOWN_AND_UP')
    chrono = datetime.datetime.now() - ts_start
    print str(iteration)+': '+str(chrono)

下面是MonkeyRunner的输出:

Here's MonkeyRunner's output:

1: 0:00:00.003000
2: 0:00:00.002001
3: 0:00:00.002001
4: 0:00:00.002001
5: 0:00:00.002000

下面是AVC的输出:

1: 0:00:00.460000
2: 0:00:00.515000
3: 0:00:00.499000
4: 0:00:00.508000
5: 0:00:00.456000

这是平均要慢200倍。

That's about 200 times slower on average.

现在看来似乎是可能的存储事件的二进制文件,然后推而直接在手机上运行它。不过,我想坚持使用纯AVC的方法。

It seems like it's possible to store events in a binary file, then pushing and running it directly on the phone. However, I'd like to stick with a pure AVC approach.

这可能吗?

编辑:

由于它是不可能的,现在要实现更好的性能,我想顺便说一下,我有一个像我提到实现事件的文件的方式。

Since it's not possible for now to achieve better performance the way I'd like to, I had to implement the event-files way like I mentioned.

我为了做到这一点使用的两个资源:

I used two resources in order to do so:

下面是如何将这些文件中的一个样子(截断):

Here is how one of those files looks like (truncated):

#!/bin/sh
sendevent /dev/input/event1 3 57 0
sendevent /dev/input/event1 3 55 0
sendevent /dev/input/event1 3 53 640
sendevent /dev/input/event1 3 54 900
sendevent /dev/input/event1 3 58 1
sendevent /dev/input/event1 0 2 0
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 0 2 0
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 3 57 0
sendevent /dev/input/event1 3 55 0
sendevent /dev/input/event1 3 53 640
sendevent /dev/input/event1 3 54 730
sendevent /dev/input/event1 3 58 1
sendevent /dev/input/event1 0 2 0
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 0 2 0
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 3 57 0
sendevent /dev/input/event1 3 55 0
sendevent /dev/input/event1 3 53 500
sendevent /dev/input/event1 3 54 900
sendevent /dev/input/event1 3 58 1
sendevent /dev/input/event1 0 2 0
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 0 2 0
sendevent /dev/input/event1 0 0 0

性能方面,它的大约两倍作为MonkeyRunner执行缓慢。

Performance-wise, it's about twice as slow as a MonkeyRunner implementation.

推荐答案

您是绝对正确的,如果你看一下$ C $ AVC和MonkeyRunner的CS,我觉得流程图如下图所示,两者都使用套接字但速度的差异是因为Monkeyrunner使用直接客户端套接字连接到服务器猴子在设备上一次猴子服务器设备上开始像水龙头,preSS发送命令。 AVC插槽亚行服务器通信,发送输入抽头/ preSS,我不知道是哪酱油是亚行输入,我想这就是Java能产生这种缓慢的响应时间。我认为AVC的所有者可以实施的眼睛一眨不眨的猴子服务器,但是有一个问题,Uiautomator和猴子不能共存在一起,所以我想他应该让速度和稳定性之间的权衡,为广大用户:

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

这篇关于AndroidViewClient的device.touch()比MonkeyRunner的要慢得多。是否可以解决吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆