Emulator is a software program that enables a system to imitate all the functions of an actual/physical device and can be used by the developer/tester to test their work without having the physical devices. Emulators can be deemed as the soft copy of the actual device for all the work that a device will perform. There are various types of emulators, for instance, Android Emulator (Android Studio), IOS Emulator (Xcode, Corellium), Delta: Multi-platform Nintendo emulator and many more.
These are open source, free to download, and very helpful when the application is in the early stage of the software development lifecycle (SDLC). Emulators can be used to get basic analytics for the native app performance.
While using the emulator, we come across several problems:-
- It is a bit sluggish, which makes the host machine slow and even we get a stuck issue very frequently.
RCA: The emulator is slow because it emulates an ARM CPU, which requires translation to Intel opcodes. This virtualization chews up the CPU.
To overcome this and increase efficiency we can change some of the settings ex-
For, WINDOWS
Under Android Studio following configuration needs to be changed-
- Install “Intel x86 Emulator Accelerator (HAXM)” => SDK-Manager/Extras
- Install “Intel x86 Atom System Images” => SDK-Manager/Android 2.3.3
- Go to the Android SDK root folder and go to C:\Users\xyz\AppData\Local\Android\Sdk\extras\intel\Hardware_Accelerated_Execution_Manager. Execute file IntelHaxm.exe to install.
Note:- (In Android Studio we can go to: Settings->Tools-> SDK manager -> Android SDK -> SDK Tools -> Intel x86 Emulator Accelerator (HAXM installer))
- Create AVD with “Intel atom x86”.
- Run emulator and check in console that HAXM is running to do so, open the Command Prompt and run the command: sc query intelhaxm )
Note:- During AVD creation add emulation memory: Hardware/New/Device ram size/set up value 512 or more
- To make the emulator faster, we should give it more CPU. Start with a fast CPU or even upgrade if needed.
To give the emulator more of the CPU we have to ways:
- Disable Hyperthreading – As the emulator does not appear to use more than one core, hyperthreading reduces the amount of overall CPU time the emulator will get. Disabling hyperthreading will slow down those apps that utilises multiple CPUs. Hyperthreading shall be disabled in the BIOS.
Enabling or disabling Intel Hyperthreading
Using the Intel (R) Hyperthreading Options option to disable/enable the logical processor cores in processors supporting Intel Hyperthreading technology. Intel Hyperthreading increases overall performance for applications that take advantage of a higher processor core count.
Procedure
- From the System Utilities screen, select Setting>Performance>Hyperthread Control.
- Select a setting Enable/Disable
- Save your setting.
Note:- Hyperthreading is not supported on all processors. For more information, we need to go through the documentation for the processor model.
- Make the emulator run on a CPU other than CPU 0 – This has a much smaller impact than turning off Hyperthreading, but it helps upto some extent. On Windows, we can choose which CPU a process will run on. Many apps use CPU 0, and by default the emulator runs on CPU 0.
To set Processor affinity the steps are as follows:-
- Open Task Manager
(Press the Windows key and type “Task Manager”& click on the Task Manager.)
- Right-click on the app that we need to modify and click “Go to details”
- Right-click on the app(emulator) in the “Details” window and choose “Set affinity”
- Select the cores we would like to assign to the program
“With the above made changes on the normal system, we shall be able to achieve an improvement of around 50 %. This will help in increasing the overall efficiency in terms of speed and battery for the system and boost the performance of Emulator.”