我目前正在进行硬件温度测试,我想知道您将如何执行最高性能任务以保持设备的所有 4 个内核都处于忙碌状态以测量峰值温度?
我当然可以用无限循环启动 n 个线程,但我认为可能有更好的方法来解决这个问题。
while (true) {
try {
new Thread() {
public void run() {
while (true) {
try {
Runtime.getRuntime().exec("ps");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}.start();
} catch (Error e) {
// typically will be OutOfMemoryerror during Thread alloc
}
}
同样在您的清单中:
<application
android:largeHeap="true"
...
adb shell top
:
User 99%, System 0%, IOW 0%, IRQ 0%
User 1216 + Nice 0 + Sys 4 + Idle 0 + IOW 0 + IRQ 0 + SIRQ 0 = 1220
PID PR CPU% S #THR VSS RSS PCY UID Name
3534 0 99% S 1292 1990880K 32784K fg u0_a56 com.myapp.cpupressure
但它仍然不如安兔兔稳定有效: