Avoid Using Floating-Point
As a rule of thumb, floating-point is about 2x slower than integer on Android-powered devices.
In speed terms, there's no difference between float and double on the more modern hardware. Space-wise,double is 2x larger. As with desktop machines, assuming space isn't an issue, you should prefer double to float.
Also, even for integers, some processors have hardware multiply but lack hardware divide. In such cases, integer division and modulus operations are performed in software—something to think about if you're designing a hash table or doing lots of math.
Math
. On versions of Android with a JIT, these are significantly slower than the equivalent
Math
functions, which should be used in preference to these.
本文介绍了在Android开发中如何优化浮点数运算性能,特别是在不同API级别下选择使用FloatMath还是Java的Math函数。对于Android API 8及更高版本,推荐使用Java的Math函数以获得更好的性能。
9万+

被折叠的 条评论
为什么被折叠?



