问题描述
我想在Android上我的移动应用的最佳性能。我想知道,如果有人知道的一招,以检查手机都有一个FPU。
I want to get the most performance of my mobile application on Android. I would like to know if someone is aware of a trick to check if the phone possesses an FPU.
一些研究似乎使用 FloatMath
类是在一个单位,都有一个FPU慢,所以我想有两全其美。之后
After some research it seems that using FloatMath
class is slower on a unit that possesses an FPU, so I would like to have best of both worlds.
大多数较新的手机都有一个FPU,但我想,以获得最佳性能的设备可以提供。
Most newer phones have an FPU, but I would like to get the most performance the device can offer.
推荐答案
这是下方的Linux内核,并且至少在默认的Android配置将安装 PROCFS
。这意味着你可以看看的/ proc / cpuinfo的
,它在ARM系统看起来是这样的:
It's a Linux kernel underneath, and at least the default Android configuration will mount procfs
. That means you can look into /proc/cpuinfo
, which on an ARM system looks something like:
# cat /proc/cpuinfo
Processor : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 249.96
Features : swp half thumb fastmult vfp edsp neon vfpv3
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x1
CPU part : 0xc08
CPU revision : 3
[ ... ]
如果在功能
行列出至少 VFP
,那么ARM的SoC具有FPU。
If the "Features
" line lists at least vfp
, then the ARM SoC has an FPU.
您应该能够阅读的/ proc / cpuinfo的
通过的Dalvik / Java接口,就像一个普通的文件,无需访问特权或任何东西。我不是一个Java程序员,所以留下,作为一个读者的工作。
You should be able to read /proc/cpuinfo
via Dalvik/Java interfaces, just like a normal file, no privileged access or anything required. I'm not a Java programmer, so leaving that as an exercise to the reader.
这篇关于检测FPU presence在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!