Giter VIP home page Giter VIP logo

e-manafa's Introduction

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_to_profile() # e.g time.sleep(10)
em.stop()
em.parse_results()
begin = manafa.perf_events.events[0].time  # first sample from perfetto
end = manafa.perf_events.events[-1].time  # last sample from perfetto
p, c, z = em.get_consumption_in_between(begin, end)
out_file = em.save_final_report(begin)
print(f"TOTAL: {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))

e-manafa's People

Contributors

rrua avatar raphael28 avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.