0

I have tested this code snippet from this discussion: Get Memory Usage in Android (Answer 14): method syncGetSystemCpuUsage.

I receive CPU utilization as 71% in my Android emulator.

Unfortunately when I run OSMonitor (https://play.google.com/store/apps/details?id=com.eolwral.osmonitor) same time, it shows CPU usage 3% same time.

How this results can be so different? Any explanations?

Community
  • 1
  • 1
javajunkie
  • 11
  • 1

1 Answers1

0

Here's my educated guess since my experience with the Android emulator is minimal though I have experience with others.

Both of the tools/code you specify are meant to execute natively (under iOS or android platform). It is probably impossible to accurately measure the CPU usage in an emulator in a modern processor. (It was possible in older processors, say 15-20 yrs ago, without modern power usage technology.)

The Android API won't work for measuring either the host CPU or the virtual CPU. CPU usage code is either very tuned to the platform or relies upon platform hardware to supply the information. In both cases, the emulated code will fail (tuned for the wrong platform or the hardware information is dummy).

So why they differ? One is designed to measure the host (iOS), and the other, native mobile hardware.

Taylor Kidd
  • 1,463
  • 1
  • 9
  • 11