Android 64bit,32bit谁更快?

这里说的64bit,32bit并不是指cpu

对于cpu来说64bit比32bit快,甚至更省电这应该已经是共识了,64bit拥有更多的寄存器,更大的位宽,更大的总线,当然更快,比如armv8有31个通用寄存器,位宽64bit,48位的寻址空间,armv7只有15个通用寄存器,位宽32bit,虽然寻址空间不是绝对的32位,但是64bit cpu更快是毋庸置疑的,特别是对大量计算的情况比如图片处理,3d游戏,声音人脸识别等等。
64bit处理器在移动端等越来越主流,ios, android等os都相继支持了64bit cpu。
但为了兼容之前的32bit生态系统,64bit cpu/os都选择了兼容32bit模式,不过以后ios/android会慢慢收紧,往64bit only的方向收紧,ios 11已经不接受32bit应用程序,android也计划在2019年8月开始在生态系统内排出32bit应用程序。
https://android-developers.go...
(需要翻墙)
64-bit support requirement in 2019

Platform support for 64-bit architectures was introduced in Android 5.0. Today, over 40% of Android devices coming online have 64-bit support, while still maintaining 32-bit compatibility. For apps that use native libraries, 64-bit code typically offers significantly better performance, with additional registers and new instructions.

In anticipation of future Android devices that support 64-bit code only, the Play Console will require that new apps and app updates with native libraries provide 64-bit versions in addition to their 32-bit versions. This can be within a single APK or as one of the multiple APKs published.

We are not removing 32-bit support. Google Play will continue to support 32-bit apps and devices. Apps that do not include native code are unaffected.

This change will come into effect in August 2019. We're providing advance notice today to allow plenty of time for developers who don't yet support 64-bit to plan the transition. Stay tuned for a future post in which we'll take an in-depth look at the performance benefits of 64-bit native libraries on Android, and check out the CPUs and Architectures guide of the NDK for more info.

但是现阶段,android os还是32bit/64bit共存的状态。

这里想讨论的或者疑问是在64bit cpu上是android 32bit runtime快还是64bit runtime快?

没有理论依据就是看问题的时候突发奇想,做了如下实验:
通过BitmapFactory的decode函数解码一张3024x4032的色彩较丰富的一张图片,大概6M,循环1000次,分别让测试apk运行在32bit和64bit运行时,然后取解码时间平均值进行比较
1.测试函数BitmapFactory.decode(“/sdcard/pic.jpg”); 执行1000次记录每次的解码时间
2.测试平台sdm845, android 8.1 框架:skia, libjpegturbo
3.查看apk运行时的是64bit还是32bit的方法:
先看你的apk的进程的父亲pid,再看这个父亲是谁zygote或者zygote64就ok了
root 1039 1 1618000 45868 0 0 S zygote
u0_a43 1892 1039 2026088 207828 0 0 S com.android.systemui
u0_a43 2465 1039 1986128 158904 0 0 S com.android.systemui:recents
u0_a149 2733 1039 1839736 46328 0 0 S com.tencent.mobileqq:MSF

测试结果:

32bit runtime解码平均时间:236ms
64bit runtime解码平均时间:246ms

32bit runtime faster?
可能一个实验并不能说明什么问题,有待深入研究。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值