Skip to main content

E-MANAFA: Energy Monitor and ANAlyzer For Android

Project description

Build Status made-with-python PyPI version PyPI license PyPI status

E-MANAFA: Energy Monitor and ANAlyzer For Android

E-MANAFA is a software model-based tool for performing fine-grained estimates of energy consumption on Android devices. For this purpose, it uses values from power_profile.xml and from the BatteryStats and Perfetto services to estimate the energy consumption of each resource / component of the device.

SETUP

In order to run this tool, the following resources are required:

Installation

pip install manafa

define environment variables

In order to run this tool, there are at least 2 env. variables that need to be defined in the shell startup script (e.g .bashrc or .bash_profile file)

export ANDROID_HOME=$HOME/<your-android-instalation-folder>/ 
export PATH=$ANDROID_HOME/platform-tools:$PATH

Replicate the environment

Install virtual virtualenv enviroment (via python-pip):

$ python -m pip install --user virtualenv

Replicate locally the dev virtualenv

$ virtualenv env/

Activate the virtual environment

$ source env/bin/activate

Extract power_profile.xml file from device (https://source.android.com/devices/tech/power/values)

Note: This file present in every device since Android 5 should contain values that were estimated by device manufacturers using external apparatus. However, most devices don't provide a fine-grained power profile. Google provides a set of instructions in order to complete this file with more accurate values(https://source.android.com/devices/tech/power/component).

TODO

Install required packages

$ pip install -r requirements.txt

Examples

# getting the energy consumed during a profiling session (between first and last measurement)
g = GreenStats(power_profile=DEFAULT_PROFILE, timezone="EST")
g.init()
g.start()
do_some_work()
batstats_out_file, perfetto_out_file = g.stop()
g.parseResults( DEFAULT_PROFILE, batstats_out_file , perfetto_out_file )
begin = g.bat_events.events[0].time
end = g.bat_events.events[-1].time
consumption,per_component_consumption = g.getConsumptionInBetween(begin, end)
print("Energy consumed: %f Joules" % consumption)

Supported devices:

This tool can be used with any Android device able to run Perfetto, that is available since Android 9 (P). The tool so far was successfuly executed on the following devices:

  • Pixel 3a
  • Pixel 4a 5G
  • Xiaomi Mi 9 Lite

TODO

  • calibrate the model
  • test using flashlight
  • wifi pixel4a

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manafa-0.2.95.tar.gz (27.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page