The Application Energy Graphing Tool for Linux is an interactive tool that can measure the battery power consumption of an application over time, and log and graph the resulting data.
Application developers can use the Application Energy Graphing Tool to help them design applications that conserve battery power on mobile computer systems.
The Application Energy Graphing Tool user interface is shown in Figure 1-1. To perform a battery utilization measurement, follow the steps below.
Figure 1-1. Application Energy Graphing Tool User Interface
Figure 1-2. Graphs
In addition to collection battery information, the Application Energy Graphing Tool for Linux also provides information on the current status of the system.
System Information
Along with the battery information, the tool also provides a few user modifiable settings for the CPU throttling governor as well as the laptop panel brightness if supported by the current system.
As shown in Figure 1-4, the user can view the current CPU throttling governor, and can set a new governor from those available on the system. The ‘Current Governor’ view will reflect the new change if the user has permissions to modify the governor. See the documentation for each governor on your system for more details on the definition.
Figure 1-5 shows the laptop panel brightness setting. Similar to the governor, it displays the current setting and the maximum, and allows the user to select a new brightness level using the slide bar.
Figure 1-4. Setting the CPU Throttling Governor

Figure 1-5. Setting the Laptop Panel Brightness

Test Results
The Application Energy Graphing Tool produces a data log and a graph containing battery power information such as the following:
- Capacity – The battery capacity, representing power used over time, reported in the units provided by the ACPI battery driver. Capacity values can be interpreted as a “fuel gauge” reading representing how much “fuel” is left in the battery. Battery life can be computed as the ratio of capacity to full charge capacity. In some systems, when the battery is fully charged, the capacity will initially appear equal to the design capacity, and then as the battery begins to discharge, it will drop sharply to the full charge capacity.
- Rate – The rate of power dissipation, representing the rate at which electrical energy is dissipated per unit time (power), reported in units provided by the ACPI battery driver, often in milliwatts (mW).
- Voltage – The voltage across the battery terminals in millivolts (mV). The voltage decreases gradually as the battery drains, but the voltage does not reflect the remaining battery life in the way that the capacity does. When the drain rate increases, the voltage will typically decrease, and then when the drain rate decreases, the voltage rebounds to nearly the voltage level before the drain rate increase. In contrast, capacity values always decrease linearly when the system is running on battery power. Each system has a maximum and minimum battery voltage requirement. When the battery reaches the minimum voltage required by the system hardware, the system shuts down.
Application Energy Command Line Tool
Description of the Tool
The Application Ener gy Command Line Tool automates the process of determining the total power consumption and net power consumption of an application running on a battery-operated system. It provides some of the same functionality as the Application Energy Graphing Tool, but enables automated testing from a command line interface or batch processing.
How the Tool Can Be Used
The Application Energy Command Line Tool can be used to determine the amount of battery power consumed when an application or test suite is run. It could be used, for example, to perform tests such as the following:
- Compare two versions of an application to see the effect of changes on average power consumption.
- Compare the average power consumption of the same workload on two different systems to help determine which system is preferable as a deployment platform.
- Test how different system power management settings affect the power consumption and performance of an application. For example, it may be possible to change the Processor Throttle Governor in a system from “performance” to “ondemand” to save battery life without affecting the performance of the application. On the other hand, if setting the Processor Throttle Governor to “ondemand” affects the speed at which the application completes a task, the difference in power consumption may be negligible.
The monitoring process can be automated, semi-automated, or manual depending on test requirements. These three methods of operation are described below:
- Automated – The application to be tested is started automatically and sampling ends automatically either after the application has finished executing or after a baseline (background) sampling period has ended (see the description of the power_evaluation command mode arguments in Section 1.2) The automated method of operation is useful in a QA setting where automated test suites are often used or in any setting where automated testing adds convenience.
- Semi-automated – The application to be tested is started automatically and sampling continues until manually stopped. This method of operation is useful to measure the power consumption of a process when the process (a separate thread) is started by a script, which terminates as soon as the process is started. For example, a script is used to activate a hard disk scan as a background thread. After the scan is started, the script returns as completed. The semi-automated method of operation allows sampling to continue until the scan is completed
- Manual – The application is started manually and sampling continues until manually stopped. This method of operation is useful when a script cannot be created to start the application. For example, the application may be started by clicking a button in a graphical user interface.
Setting Up and Executing a Test
A power evaluation test is set up using one or more of the following components:
- The executable program to be tested or a shell script that runs the processes to be tested.
- The power_evaluation command. A detailed description is provided below.
- An encapsulation script to set variables and run the components required for the test.
The power_evaluation command syntax is:
appenergy [-m mode] [-w workload] [-i interval] [-d duration] –l log
The command arguments are:
-m <mode>
Selects the mode for the test. Options include:
- Measures the total battery power consumed during the time the test program is running. Mode 1 requires a system running on a single battery.
Note: For comparative studies, mode 1 is preferred over mode 2. In a comparative study, only one test variable, such as a certain application feature, is changed, while the test configuration and all other system parameters are kept constant. Under such conditions, the background power consumption remains constant. Therefore, the difference in power consumption between the two test conditions can be obtained by comparing the total power consumption for each test run. The advantage of using mode 1 (total power consumption) over mode 2 (net power consumption) is a shorter runtime, which reduces variability in the test results.
- Measures the net battery power consumed while the test program is running. First, the total power consumed is measured during the time the test program is running. The total power consumed is then measured again during a test interval of equal length to the test program run time. Finally, the difference between the two results is calculated to determine the net power consumed while the program was running.
Note: The output result in Mode 2 can be affected if other processes are started or stopped on the system during the test run. Mode 2 requires a system running on a single battery.
-d duration
- Sets the duration for which data is to be collected in seconds. A setting of 0 (zero) will force indefinite collection until the user stops collection manually, or the workload completes.
-i interval
- Sets the interval at which data is collected in seconds. The default sampling interval is 5 seconds.
-w <program/shell-script to evaluate>
- Identifies the workload to be evaluated or a shell script running processes to be evaluated. The program or script should run at least 30 seconds.
Note: On some systems, battery information may be updated so infrequently that the systematic error due to the update frequency is more then 5%.When this happens, the Application Energy Command Line Tool will display a warning message and the test will need to be repeated with a longer run time.
<program arguments>
- Specifies arguments to be used by the test program. This will be included in quotes as an argument to the -w switch.
-l <logfile>
- Specifies the path to the log file that th e command line tool generates. The name and location of this file can be changed by changing the argument passed in to the -l switch. For example, to set the output file to /home/jimbo/power_output.dat, enter:
appenergy -m 2 -w “./program.sh” -l “/home/jimbo/power_output.dat”
Note: To prevent overwriting the output log file during a subsequent test run, the log file should be moved or renamed after a test run is completed, or the -l argument should be set to a new value.
Automated Test Example
To run an automated test that measures the net power consumed during the test interval by a test suite, follow steps similar to those shown below:
- Prepare a shell script to run the test suite (test.sh).
- To run the power evaluation test, enter the following command in the command line tool console window:
appenergy -m 2 –d 300 -w “./test.sh” -l “/home/jimbo/power.log”
- To view results, enter:
cat /home/jimbo/power_.log
The results are saved in the log file in a comma-separated format, which can be viewed in a spreadsheet application such as Open Office Calc.
Manual Test Example
To run a manual test that measures the total power consumed during the test interval by a test suite, follow steps similar to those shown below:
- Enter a command such as the following in the terminal window:
appenergy -m 1 –i 10 -l “/home/jimbo/power.log”
Sampling begins and a message “Press ESC to quit” appears.
- Wait 10 seconds. A 10 second count down will appear in the console window.
- Manually start the program or test suite to be tested.
- Allow the test to run at least 30 seconds.
- Press the ‘ESC’ key to manually stop the test.
- To view results, enter:
cat /home/jimbo/power.log
The results are saved in the log file in a comma-separated format for easy viewing in a spreadsheet application such as Open Office Calc.
Test Results
This tool makes calculations based on the discharge and capacity information provided by the battery through the Advanced Configuration and Power Interface (ACPI). The results provided by the Application Energy Command Line Tool may therefore not be as precise as many factors can affect the accuracy of this information and measurements may vary from system to system.
The output log file contains three sections. The first section displays a number of calculated values, such as the following:
- Total power consumption – Calculated by integrating the discharge rate over the sample interval.
- Change in battery capacity – Calculated by finding the difference between the battery capacity at the beginning and at the end of the sample period.
- Average power consumption – Calculated by dividing the change in battery capacity by the elapsed time.
- Battery drain rate information update interval (max) in seconds.
- Battery capacity information update interval (max) in seconds.
- The systematic error due to granularity of the battery information update.
The second section contains information that can be used to evaluate the quality of the data obtained. In this section, average power consumption is calculated by integrating the discharge rate over the sample interval and dividing by the elapsed time. Thus, the value for average power consumption in this section may differ from the value that appears in the first section.
In the third section, the following information is provided for each data point:
- Sample_number – A sequential number assigned to each sample taken.
- Time (sec) – The time elapsed since sampling began.
- Capacity (mWh) – The amount of charge left in the battery.
The results are saved in the log file in a comma-separated format viewable in a spreadsheet application such as Open Office Calc.
Points to Remember
- For comparison studies, all tests should be performed with the battery at the same battery capacity level. Generally, it is best to perform measurements with a completely charged battery and to recharge the battery between tests.
- Be aware of the limitations of the Application Energy Command Line Tool when comparing different runs.
- Perform the measurement multiple times.
- The power usage and performance of an application are, in general, significantly affected by the selected power management schema.
- Power management schema definitions may vary between platforms.
- The display brightness setting affects power consumption.
- The Application Energy Command Line Tool provides information about the active processor throttle mode at startup.
- The active power management schema, the processor throttle mode, and the brightness setting should be recorded for each measurement.
Additional notes about Application Energy Command Line Tool:
- The system should be run on batteries at least one minute before starting the Application Energy Command Line Tool to allow time for system power status variables to be updated.
- Based on extensive field tests, battery drivers provide updated values at intervals ranging from 2 to 30 seconds.
- The minimum execution time that can be evaluated is 30 seconds and the systematic error due to the battery update interval must be less than 5%. The Application Energy Command Line Tool will not report results for runs shorter than 30 seconds or when the systematic error is larger then 5%.
- Running a test longer for a longer period of time will increase the accuracy of the results because they will be based on a larger number of capacity and drain rate samples.
- The test must not drain the battery completely, as the Application Energy Command Line Tool must be able to compute and write results to a file at the end of the test.
- System settings must be set such that the system will not go on standby or hibernate while measurements are being taken, and that the screensaver will not be activated during the baseline (background) measurement phase in mode 2.
How Application Energy Command Line Tool Works
When the command is run with mode set to 2, the resulting output is the net power consumed while the test program or suite is running. The steps described below and shown in Figure 2-1, show how data samples are obtained and test results calculated for mode 2:
- The test cycle starts with a 10 second idle time to allow values such as drain rate, capacity, and CPU utilization to be updated and propagate through the system. The five samples taken during the idle time are discarded.
- A time stamp is taken to designate the beginning of the application test period.
- The Application Energy Command Line Tool starts the program or test suite batch script.
- Sampling continues until the program completes execution.
Data sampled includes:
- Battery discharge rate
- Battery capacity
- A time stamp is taken to designate the end of the application test period.
- Another 10-second idle time takes place during which five samples are taken and discarded.
- The Application Energy Command Line Tool samples for another time period equal to the application sample period, as determined using the time stamps.
- A final 10-second idle time takes place during which five samples are taken and discarded.
- The Application Energy Command Line Tool calculates the following for both the application and baseline sample periods:
- Total power consumption
- Change in battery capacity
- Average power consumption
- The Application Energy Command Line Tool calculates the net power consumption by subtracting the total power consumption calculated for the baseline sample period from the total power consumption calculated for the application sample period.
- Output results are written in comma-delimited format to the file specified with the /log switch. A spreadsheet application such as Open Office Calc can be used to view and manipulate the data.
Figure 2-1. Application Energy Command Line Tool Test Cycle in Mode 2
