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?
可能一個實驗並不能說明什麼問題,有待深入研究。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章