Appower uses the Intel Running Application Power Limit (RAPL) through the raplcap
library, which provides a C interface for interacting with RAPL. However, RAPL only provides the energy consumption of the entire CPU. Appower is developed to measure the specific power consumption of a single software application running on a Linux computer with an Intel processor.
Before using Appower, ensure you have the following prerequisites installed on your Linux environment (Ubuntu focal):
- Linux environment (Ubuntu focal) with Intel processor
- Python 3
- Pip
- CMake
To install Appower on your system, follow change to project root and run installation script
cd appower
source ./install
Always activate virtual environment with source .venv/bin/activate
before using, because required libraries were installed there
To use Appower, you can run it from the terminal and specify the path to the executable and its arguments:
./appower /path/to/executable arg1 arg2 arg3
Note: Appower uses RAPL, which requires elevated permissions (sudo). Therefore, root user permission will be required.
An example program has been provided at the project level directory to demonstrate how to use Appower:
(.venv)$: ./appower
Please enter the full path of the application/program (must be an executable):
/home/your_username/projects/test_appower 30
- Power consumed by the CPU while the application is not running: x
- Power consumed by the CPU while the application is running: x + a (where a is the additional power consumed by the application)
- Power consumed by the application alone: a (obtained by subtracting x from x + a)
-
CPU Selection: The application process and its children processes' CPU affinity are set to a single processor to ensure proper energy reading from a specific CPU.
-
Energy Monitoring: The initial energy reading (before application execution) of the RAPL PACKAGE ZONE is recorded.
-
Application Execution: The target application is executed with the provided arguments.
-
Energy Monitoring (After Execution): The final energy reading is obtained after the application completes.
-
Power Consumption Calculation: The energy consumed by the application is calculated as the difference between the final and initial energy readings.
-
Baseline Power Consumption: To exclude background application data, the power consumption of the CPU during normal operation is measured over a specific period (default: 60 seconds).
-
Final Power Consumption: The power consumed by the application alone is obtained by subtracting the baseline power consumption from the total power consumption.