本文介绍了在 Android 上检测 FPU 的存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 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.

经过一些研究,似乎在拥有 FPU 的单元上使用 FloatMath 类会比较慢,所以我想两全其美.

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
[ ... ]

如果Features"行至少列​​出了 vfp,则 ARM SoC 具有 FPU.

If the "Features" line lists at least vfp, then the ARM SoC has an FPU.

您应该能够通过 Dalvik/Java 接口读取 /proc/cpuinfo,就像普通文件一样,无需特权访问或任何需要.我不是 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.

这篇关于在 Android 上检测 FPU 的存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-10 03:56