如果未选中 USB 调试,Log.x() 是否会占用任何 CPU?

发布于 2024-12-10 04:42:19 字数 540 浏览 4 评论 0原文

我知道,为了加快速度并在应用程序发布时消除 CPU 浪费,我可以简单地使用 proguard.cfg 导出它,其中包含:

-assumenosideeffects class android.util.Log {
    public static *** v(...);
    public static *** i(...);
    public static *** d(...);
    public static *** w(...);
    public static *** e(...);
}

但是...如果,为了方便地最小化杂耍在调试版本和发布版本之间(始终需要在安装另一个版本之前完全卸载一个版本),我希望始终运行调试版本,不通过 USB 连接并使用 Settings =>;应用=>发展=> USB 调试 未选中,Log.v()、Log.i() 等是否会被执行?

我无法真正通过 USB 连接 DDMS 来检查这一点...所以,感谢您的任何提示。

I know that to speed up things and eliminate CPU waste when an application is released, I can simply export it with proguard.cfg containing:

-assumenosideeffects class android.util.Log {
    public static *** v(...);
    public static *** i(...);
    public static *** d(...);
    public static *** w(...);
    public static *** e(...);
}

But... if, for the purpose of convenient minimization of the juggle between Debug and Release version (which always requires a full uninstall one one before installing the other), I want to always run the debug version, without being connected via USB and with Settings => Applications => Development => USB debugging unchecked, do any of the Log.v(), Log.i(), etc. get executed at all?

I can't really connect DDMS via USB to check this myself... so, thanks for any tip.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萝莉病 2024-12-17 04:42:19

它仍然会将您的日志消息写入内部日志缓冲区。

市场上有一些应用程序可以显示此缓冲区,其中之一称为 Android System Info 或类似的东西,AFAIR。

It will still write your log message to an internal log buffer.

And there's some apps on the Market that can show this buffer, one of them called Android System Info or something like that, AFAIR.

喵星人汪星人 2024-12-17 04:42:19

根据 ProGuard 手册 ( http://proguard.sourceforge.net/index .html#/manual/usage.html ):

-假设副作用类规范

指定没有任何副作用(除了可能返回值之外)的方法。在优化步骤中,如果 ProGuard 可以确定未使用返回值,它将删除对此类方法的调用。请注意,ProGuard 会分析您的程序代码以自动查找此类方法。它不会分析库代码,因此此选项很有用。例如,您可以指定方法 System.currentTimeMillis(),以便删除对其的任何空闲调用。请注意,ProGuard 将该选项应用于指定方法的整个层次结构。仅适用于优化时。一般来说,做出假设可能是危险的。您可以轻松地破坏已处理的代码。仅当您知道自己在做什么时才使用此选项!

因此,对 Log.v()、Log.i() 等的调用甚至不存在于 APK 中。

According to the ProGuard manual ( http://proguard.sourceforge.net/index.html#/manual/usage.html ):

-assumenosideeffects class_specification

Specifies methods that don't have any side effects (other than maybe returning a value). In the optimization step, ProGuard will then remove calls to such methods, if it can determine that the return values aren't used. Note that ProGuard will analyze your program code to find such methods automatically. It will not analyze library code, for which this option can thus be useful. For example, you could specify the method System.currentTimeMillis(), so that any idle calls to it will be removed. Note that ProGuard applies the option to the entire hierarchy of the specified methods. Only applicable when optimizing. In general, making assumptions can be dangerous; you can easily break the processed code. Only use this option if you know what you're doing!

So the calls to Log.v(), Log.i(), etc don't even exist in APK.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文