被合并类与ProGuard的建议在Android / Dalvik的? [英] Is merging classes with ProGuard recommended on Android/Dalvik?

查看:196
本文介绍了被合并类与ProGuard的建议在Android / Dalvik的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这只是发生,我认为我们使用,即合并类层次结构ProGuard的code优化的一个,也许不会是一个不错的选择的。

It just occurred to me that one of the ProGuard code optimizations we used, namely merging class hierarchies, may perhaps not be a good choice at all.

我的直觉是,这将是有益的合并班,以减少对ClassLoader中,这至少在JVM是一种特别缓慢的操作,并在我们的code,我们选择了很多小的调用(常内部)类,而不是大神的对象类,因此类加载器将运行比较频繁。

My hunch was that it would be beneficial to merge classes in order to cut down on invocations of the ClassLoader, which at least on a JVM is a particularly slow operation, and in our code we opted for many smaller (often inner) classes rather than large God object classes, so the ClassLoader will run relatively often.

但是,由于所有的类将被合并成一个单一的极端(大概不太可能)情况,那么即使装载器将只调用一次,我们最终将装载吨code到内存中即会很可能永远不会被使用(80/20法则在这里也适用我猜的)。

However, given the extreme (probably unlikely) case that all classes would be merged into a single one, then even though the loader would only be invoked once, we would end up loading tons of code into memory that will very likely be never used (80/20 rule applies here as well I guess).

这让我疑惑:

1)如何快的类加载在Dalvik的实际?难道是值得使用类合并都削减操作?

1) How fast is class loading in Dalvik actually? Is it an operation that is worth cutting down on by using class merging at all?

2)这就是说,你会建议使用类合并都在Android?

2) That said, would you recommend using class merging at all on Android?

推荐答案

垂直类合并崩溃类/接口与扩展/实现时,这些都是不必要的分裂。这应该永远是一个改善(尺寸和性能)。

Vertical class merging collapses classes/interfaces with their extensions/implementations when these are needlessly split. That should always be an improvement (size and performance).

有关水平一流合并,我不能提供一个笼统的回答。在code基会小一点,但有些code可以想见,不久将加载到,或者在极端情况下,不必要的。

For horizontal class merging, I can't provide a general answer. The code base will be smaller, but some code could conceivably be loaded to soon, or in the extreme, unnecessarily.

这篇关于被合并类与ProGuard的建议在Android / Dalvik的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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