简体   繁体   English

如何有意减慢模拟器的速度?

[英]How to intentionally slow down the emulator?

This question goes the opposite direction than the usual about Android emulators. 这个问题与通常关于Android模拟器的方向相反。

My Android instrumentation tests (using Espresso against the RxJava-based app) run just fine on my development machine, but they occasionally fail in the build server. 我的Android测试测试(使用Espresso对抗基于RxJava的应用程序)在我的开发机器上运行得很好,但它们偶尔会在构建服务器中失败。

My build server has a slower hardware than my machine. 我的构建服务器的硬件比我的机器慢。 I think this is causing the actual Espresso checks to be performed before the background tasks have been completed. 我认为这导致在后台任务完成之前执行实际的Espresso检查。 I'm aware that Espresso, by default, does not wait for RxJava schedulers (io() and computation()) to complete, so that may be the reason. 我知道Espresso默认情况下不会等待RxJava调度程序(io()和calculate())完成,所以这可能就是原因。

There are several ways to make Espresso aware of RxJava schedulers, but before implementing them I want to reproduce the problem on my machine. 有几种方法可以让Espresso了解RxJava调度程序,但在实现它们之前,我想在我的机器上重现问题。

I've tried disabling hardware acceleration to no avail. 我试过禁用硬件加速无济于事。

In the configuration you can set the network speed and latency, but in this case I'm interested in throttling down CPU speed. 在配置中,您可以设置网络速度和延迟,但在这种情况下,我有兴趣限制CPU速度。 There is no network involved in the failing tests. 失败的测试中没有涉及网络。

There's no way to slow down the Android emulator, and even it that was possible, it won't expose more race conditions because both "parts of the race" are slowed down together, in this case Espresso and RxJava's background tasks. 没有办法减慢Android模拟器的速度,即使它是可能的,它也不会暴露更多的竞争条件,因为两个“比赛的部分”一起放慢了速度,在这种情况下Espresso和RxJava的后台任务。

It's better to focus instead on reproducing locally the same environment where the issue occurred. 最好将注意力集中在本地再现发生问题的相同环境。

Try to edit configuration of your Emulator in AVD Manager, I just decreased RAM and Cores number and my tests started to fail more often:) 尝试在AVD Manager中编辑模拟器的配置,我只是减少了RAM和核心数量,我的测试开始更频繁地失败:)

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM