Energy Profiler for Android Emulator
Diego Ruggeri
diego@ruggeri.net.br
Project Proposal Energy-Aware Computing 2
Project Outline
Energy Profiler for Android Emulator
• Project Summary
• Android Emulator
• Energy Model Archtecture
• Code
• Demo
Project Proposal Energy-Aware Computing 3
Project Summary
• Add instrumentation to Android Emulator to capture hardware events, duty
cycle, clock frequency, etc.
• Use existing power models to predict consumption in real devices
• Empowering Developers to Estimate App Energy Consumption
• Modem state machine
Project Proposal Energy-Aware Computing 4
Android Emulator
• Two versions of android emulator
• The first is a fork of qemu, incompatible with the mainline (repo qemu)
It emulates a hardware called goldfish, which has an specific android
kernel for it.
• The newer one was started by linaro to support arm v8 64 bits using
qemu 2.0 source code and is now default (repo qemu-android)
The emulated hardware is called ranchu
It is periodically rebased on top of latest qemu
• Tracetool generates tracing glue code for multiple backends
A file trace-events specify events end formats
Project Proposal Energy-Aware Computing 5
Android Emulator
• To build you need to use repo tool to download multiple gits
• Total was about 8 GB of code, 11 GB after building
• I used the studio-dev branch
• Then switched to the most up-to-date is emu-master-dev
• qemu, android-qemu
• dependencies, libs
• sdk, ndk
• cross-compilers: gcc (linux), clang (mac), mingw (windows)
• 32 and 64 bits
• kernel
Project Proposal Energy-Aware Computing 6
Android Emulator
https://github.com/android-energy/platform_external_qemu/blob/emu-
master-dev/docs/ANDROID-EMULATION-LIBRARY.TXT
Project Proposal Energy-Aware Computing 7
Energy Model Archtecture
- Modem
- GPS
- Screen
- Wifi
- CPU
Project Proposal Energy-Aware Computing 8
Energy Model Archtecture
• Python Implementation
• Invoke an modified emulator which print logs on stderr
• Each component can register to be notified if some tag appear on the log
• Each component run on its own thread and compute its power according to
the models
• The device model sums the power of its components
• The only compoent implemented was the modem
• Each time the driver sends a message, the modem goes to active mode
(DCH), and after some time will transition to intermediate states until it goes to
sleep again or goes back to DCH.
Project Proposal Energy-Aware Computing 9
Code: Modem States
Project Proposal Energy-Aware Computing 10
Code: State Transition
Project Proposal Energy-Aware Computing 11
Code: Device Model
Project Proposal Energy-Aware Computing 12
Demo

Energy profiler for android emulator

  • 1.
    Energy Profiler forAndroid Emulator Diego Ruggeri diego@ruggeri.net.br
  • 2.
    Project Proposal Energy-AwareComputing 2 Project Outline Energy Profiler for Android Emulator • Project Summary • Android Emulator • Energy Model Archtecture • Code • Demo
  • 3.
    Project Proposal Energy-AwareComputing 3 Project Summary • Add instrumentation to Android Emulator to capture hardware events, duty cycle, clock frequency, etc. • Use existing power models to predict consumption in real devices • Empowering Developers to Estimate App Energy Consumption • Modem state machine
  • 4.
    Project Proposal Energy-AwareComputing 4 Android Emulator • Two versions of android emulator • The first is a fork of qemu, incompatible with the mainline (repo qemu) It emulates a hardware called goldfish, which has an specific android kernel for it. • The newer one was started by linaro to support arm v8 64 bits using qemu 2.0 source code and is now default (repo qemu-android) The emulated hardware is called ranchu It is periodically rebased on top of latest qemu • Tracetool generates tracing glue code for multiple backends A file trace-events specify events end formats
  • 5.
    Project Proposal Energy-AwareComputing 5 Android Emulator • To build you need to use repo tool to download multiple gits • Total was about 8 GB of code, 11 GB after building • I used the studio-dev branch • Then switched to the most up-to-date is emu-master-dev • qemu, android-qemu • dependencies, libs • sdk, ndk • cross-compilers: gcc (linux), clang (mac), mingw (windows) • 32 and 64 bits • kernel
  • 6.
    Project Proposal Energy-AwareComputing 6 Android Emulator https://github.com/android-energy/platform_external_qemu/blob/emu- master-dev/docs/ANDROID-EMULATION-LIBRARY.TXT
  • 7.
    Project Proposal Energy-AwareComputing 7 Energy Model Archtecture - Modem - GPS - Screen - Wifi - CPU
  • 8.
    Project Proposal Energy-AwareComputing 8 Energy Model Archtecture • Python Implementation • Invoke an modified emulator which print logs on stderr • Each component can register to be notified if some tag appear on the log • Each component run on its own thread and compute its power according to the models • The device model sums the power of its components • The only compoent implemented was the modem • Each time the driver sends a message, the modem goes to active mode (DCH), and after some time will transition to intermediate states until it goes to sleep again or goes back to DCH.
  • 9.
    Project Proposal Energy-AwareComputing 9 Code: Modem States
  • 10.
    Project Proposal Energy-AwareComputing 10 Code: State Transition
  • 11.
    Project Proposal Energy-AwareComputing 11 Code: Device Model
  • 12.