views:

566

answers:

3

I'm looking into writing an Android game, tough I don't curerntly own an Android device. For those of you who own a device, how does the performance on the emulator relate to real device performance? I'm especially interested in graphics related tasks.

This obviously depends on both the machine running the emulator, and the specific device in question, but I'm talking rough numbers here.

This question is a duplicate, but since that post is heavily outdated, I figured it's irrelevant by now.

+4  A: 

Generally speaking, the emulator is much slower than a device at CPU and GPU tasks. That's for at least two reasons:

  1. The emulator is running ARM opcodes, converting them into equivalent x86 instructions, which is slow
  2. Devices (usually) have graphics accelerators, whereas the emulated environment does not, despite whatever video card you have on the machine running the emulator

To put things in perspective, I do my Android work on an Intel quad-core 2.66GHz with a fairly nice graphics card. For videos that work fine on devices, I can sometimes get them to play back in the emulator.

The emulator is faster than a device, though, at "disk" I/O. When you write to "flash" on the emulator, you are writing to a disk image file that probably resides on a regular hard drive, assuming you're not using an SSD. Actually writing to flash on a device can be massively slower -- Brad Fitzpatrick, at last week's Google I|O 2010 conference, cited spikes of up to 200ms to write a single byte to flash. And, the combination of Android, flash, and the yaffs2 filesystem apparently causes a device to get progressively slower at flash I/O as the flash fills up. Hence, his recommendation was to do any flash writes in a background thread instead of the main application thread, where it can tie up the UI and lead to a "janky" app.

(apparently, "janky" is a technical term... :-)

BTW, when it shows up online, definitely watch Brad's presentation on YouTube. It may be a bit difficult to follow at times, because he spoke very quickly, but it was full of useful tidbits related to performance.

CommonsWare
Thanks, that's helpful information. On the same issue, does the emulator use the same VM as a device? In particular, should I expect similiar GC activity?
uj2
If by "VM" you mean the Dalvik VM for running apps written in Java, then yes. In terms of GC activity, the only source of potential difference is in the application heap max size. Older devices, and I think the emulator, limit you to a 16MB heap. Newer devices with more RAM and bigger screens support a 24MB heap. It is unclear if there's a way to control the app heap size in the emulator. You probably want to do your testing on the smaller heap size, anyway.
CommonsWare
I've had runtime issues with code on emulator, a tabactivity took 8-10 seconds to load on emulator, on real device tooks 1-2 seconds, barely visible lag.
Pentium10
A: 

The conversion of ARM opcodes to x86 as mentioned is the main source of lag in the emulator.

In my experience, the emulator is very slow indeed and is very unrepresentative of what may be expected from a device, especially a Snapdragon processor.

Even extremely basic applications in the emulator (I'm talking a LinearLayout with a couple of TextViews) take a while to load and execute activity.

Mostly, though, the lag seems to be initial. By that, I mean if you scroll a list in the emulator, it will take a second to recognise the action and be a little jerky at first, but it becomes smoother afterwards.

In short, I would not recommend developing a game with the use of the emulator for anything other than initial programming, debugging and perhaps seeing how activities are laid out. You will not have any idea of playability without a real device.



P.S. Don't forget to test your game on various versions of Android and look for common problems games encounter in various versions of Android.

HXCaine
I wish they compiled the emulator for x86 like Palm did with their webOS emulator, despite the fact their phones use a version of webOS compiled for ARM processors. Can't this be easily done with Android as well?
Vitaly
+1  A: 

Check this nice article where it's shown how one can compare the CPU speed of emulator with the CPU speed of device using BogoMIPS.

Sagar