艺术:X的验证花费了Y ms [英] Art: Verification of X took Y ms

查看:157
本文介绍了艺术:X的验证花费了Y ms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的logcat中有一个警告:

I've got a warning in my logcat:

W/art: Verification of void com.myapp.LoginFragment$override.lambda$logIn$5(com.myapp.LoginFragment, java.lang.Throwable) took 217.578ms

代码如下:

subscription = viewModel.logIn()
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
               this::showStudioSelection,
               error -> {
                    ErrorResponse errorResponse = ErrorResponseFactory.create(error);

                    if (errorResponse.code() == ApiResult.BAD_REQUEST) {
                       Snackbar.make(getView(), R.string.login_bad_credentials, Snackbar.LENGTH_LONG)
                            .setAction(android.R.string.ok, v -> {})
                            .show();
                    } else {
                        Snackbar.make(getView(), "Unknown error " + errorResponse.code(), Snackbar.LENGTH_LONG)
                            .setAction(android.R.string.ok, v -> {})
                            .show();
                    }
                    viewModel.updateLoginButtonState();
                 }
            );

220ms相当多(我感觉我注意到该片段的启动滞后了)。

220ms is quite a lot (and I feel like I'm noticing a lag on startup of that Fragment).

我正在使用RxJava和retrolambda,但这不是此消息弹出的唯一位置,因此我认为它没有直接关系。

I'm using RxJava and retrolambda, but this is not the only spot where this message pops up so I don't think it's directly related.

我如何影响验证时间?值得吗?

似乎与圈复杂度有关,因为我可以通过删除 if Snackbar.make 调用来摆脱警告。 c>还有一些 dry 代码:

It seems like it has something to do with cyclomatic complexity, since I could get rid of the waring by removing the Snackbar.make calls in the if with some more dry code:

String errorMessage;
if (errorResponse.code() == ApiResult.BAD_REQUEST) {
    errorMessage = getString(R.string.login_bad_credentials);
} else {
    errorMessage = "Unknown error " + errorResponse.code();
}


推荐答案

这似乎是一部分较新的 ART 运行时的向后兼容性要求。也就是说,针对 DALVIK 构建的应用也需要能够在 ART 上运行。

It looks like this is part of the 'backwards compatibility' requirement for the newer ART runtime. That is, apps built against DALVIK need to be able to run on ART as well.

如果您在ART系统上运行 DVM 应用,则在 dex2oat 转换应用程序。如果您构建针对 ART 的应用程序,则该应用程序将不再能够在 DVM 上运行,而不能在 OAT 转换将在安装过程中发生,并且在运行时看不到。

If you run a DVM app on an ART system, you'll see this message the first time it runs when dex2oat converts the application. If you build the application targeting ART, the app will no longer be able to run on DVM, but the OAT conversion will happen during installation and is not seen at runtime.

来源:艺术的艺术 请注意,这是对ART的三部分调查的一部分,您可能需要检查一下部分两个三个

Source: The Art of Art note this is part one of a three part investigation of ART and you may need to check parts two and three

这篇关于艺术:X的验证花费了Y ms的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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