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 DOI

E-MANAFA: Energy Monitor and ANAlyzer For Android

E-MANAFA is a plug-and-play software model-based tool for performing fine-grained estimates of energy consumption on Android devices. E-Manafa estimates system-level and per-component energy consumption, by extracting information from the following sources:

  • power_profile.xml: Device-specific file provided by manufacturers containing current consumption per component state;
  • batterystats: Tool from Android framework that logs each power-related event that occurs between device charges;
  • Perfetto: System-wide profiling for Linux and Android, that profiles high-frequency data, such as CPU frequency.

Note: Manufacturers not always supply information about the current consumed by an individual component in the power profile file. Use this information if it accurately represents the current drawn from the device battery in practice. The file can also be derived using external apparatus such as Monsoon. Google provides a set of guidelines to estimating the current of each component (https://source.android.com/devices/tech/power/component)

Documentation

https://greensoftwarelab.github.io/E-MANAFA/modules.html

SETUP

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

Installation

1. Via python-pip

pip install manafa

1.1 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

2. From sources

2.1 Clone repo

$ git clone https://github.com/greensoftwarelab/E-MANAFA.git

2.2 Replicate the environment

Install virtual virtualenv enviroment (via python-pip):

$ python -m pip install --user virtualenv

2.3 Replicate locally the dev virtualenv

$ virtualenv env/

2.4 Activate the virtual environment

$ source env/bin/activate

2.5 Install required packages

$ pip install -r requirements.txt

2.6 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

Usage

Command line

$ emanafa [-p|--profile <prof>] 
          [-t|--timezone <tz>] 
          [-pft|--perfettofile <pf>] 
          [-bts|--batstatsfile <bf>] 

From project's root

$ python3 emanafa.py [-p|--profile <prof>] 
                     [-t|--timezone <tz>] 
                     [-pft|--perfettofile <pf>] 
                     [-bts|--batstatsfile <bf>] 

Source

# Example 
em = EManafa()
em.init()
em.start()
do_work() # e.g time.sleep(10)
em.stop()
begin = em.perf_events.events[0].time if len(em.perf_events.events) > 1 else em.bat_events.events[0].time
end = em.perf_events.events[-1].time if len(em.perf_events.events) > 1 else em.bat_events.events[-1].time
p, c, z = em.get_consumption_in_between(begin, end)
out_file = em.save_final_report(begin)
print(f"Energy consumed: {p} Joules")

TODO

  • support for all timezones
  • support for memory power calculator (MemoryPowerCalculator is a new addition in 8.0, mainly to count the power consumption on DDR memory . formula: MemoryPower = (mAatRail_1 * timeMs_1 + mAatRail_2 * timeMs_2 +… + mAatRail_n * timeMs_n) / (1000 * 60 * 60) (mAatRail_n: is the power at the read/write rate level, timeMs_n: is the time at the mAatRail_n level))

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.3.128.tar.gz (22.7 MB view details)

Uploaded Source

File details

Details for the file manafa-0.3.128.tar.gz.

File metadata

  • Download URL: manafa-0.3.128.tar.gz
  • Upload date:
  • Size: 22.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.2

File hashes

Hashes for manafa-0.3.128.tar.gz
Algorithm Hash digest
SHA256 c5507726d08365ae11e7cceee57ce71cf17b255adbded2114d6e86e32b4bcbda
MD5 766f9f1b80a58c4aa058a127f8c3fde6
BLAKE2b-256 1bd43303d69b4e9d5960872d0b34b2cbba2145d4cb05f49ff3f33809054dbffa

See more details on using hashes here.

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