Energy Consumption Estimation of API-usage in Smartphone Apps via Static Analysis

Abdul Ali Bangash and Kalvin Eng and Qasim Jamal and Karim Ali and Abram Hindle

2023/03/07

Energy Consumption Estimation of API-usage in Smartphone Apps via Static Analysis

Authors

Abdul Ali Bangash and Kalvin Eng and Qasim Jamal and Karim Ali and Abram Hindle

Venue

Abstract

Smartphone application (app) developers measure the energy consumption of their apps to ensure that they do not consume excessive energy. However, existing techniques require developers to generate and execute test cases on expensive, sophisticated hardware. To address these challenges, we propose a static-analysis approach that estimates the energy consumption of API usage in an app, eliminating the need for test case execution. To instantiate our approach, we have profiled the energy consumption of the Swift SQLite API operations. Given a Swift app, we first scan it for uses of SQLite. We then combine that information with the measured energy profile to compute E-factor, an estimate of the energy consumption of the API usage in an app. To evaluate the usability of E-factor, we have calculated the E-factor of 56 real-world iOS apps. We have also compared the E-factor of 16 versions and 11 methods from 3 of those apps to their hardware-based energy measurements. Our findings show that E-factor positively correlates with the hardware-based energy measurements, indicating that E-factor is a practical estimate to compare the energy consumption difference in API usage across different versions of an app. Developers may also use E-factor to identify excessive energy-consuming methods in their apps and focus on optimizing them. Our approach is most useful in an Integrated Development Environment (IDE) or Continuous Integration (CI) pipeline, where developers receive energy consumption insights within milliseconds of making a code modification.

Bibtex

@inproceedings{bangash2023MSR-static-energy,
 abstract = {Smartphone application (app) developers measure the energy consumption of their apps to ensure that they do not consume excessive energy. However, existing techniques require developers to generate and execute test cases on expensive, sophisticated hardware. To address these challenges, we propose a static-analysis approach that estimates the energy consumption of API usage in an app, eliminating the need for test case execution. To instantiate our approach, we have profiled the energy consumption of the Swift SQLite API operations. Given a Swift app, we first scan it for uses of SQLite. We then combine that information with the measured energy profile to compute E-factor, an estimate of the energy consumption of the API usage in an app. To evaluate the usability of E-factor, we have calculated the E-factor of 56 real-world iOS apps. We have also compared the E-factor of 16 versions and 11 methods from 3 of those apps to their hardware-based energy measurements. Our findings show that E-factor positively correlates with the hardware-based energy measurements, indicating that E-factor is a practical estimate to compare the energy consumption difference in API usage across different versions of an app. Developers may also use E-factor to identify excessive energy-consuming methods in their apps and focus on optimizing them. Our approach is most useful in an Integrated Development Environment (IDE) or Continuous Integration (CI) pipeline, where developers receive energy consumption insights within milliseconds of making a code modification.},
 accepted = {2023-03-07},
 author = {Abdul Ali Bangash and Kalvin Eng and Qasim Jamal and Karim Ali and Abram Hindle},
 authors = {Abdul Ali Bangash and Kalvin Eng and Qasim Jamal and Karim Ali and Abram Hindle},
 booktitle = {2023 IEEE/ACM 20th International Conference on Mining Software Repositories (MSR)},
 code = {bangash2023MSR-static-energy},
 date = {2023-05-15},
 funding = {NSERC Discovery},
 location = {Melbourne, Australia},
 pagerange = {272--283},
 pages = {272--283},
 rate = {37%},
 role = {Co-Author},
 title = {Energy Consumption Estimation of API-usage in Smartphone Apps via Static Analysis},
 type = {inproceedings},
 url = {http://softwareprocess.ca/pubs/bangash2023MSR-static-energy.pdf},
 venue = {2023 IEEE/ACM 20th International Conference on Mining Software Repositories (MSR)},
 year = {2023}
}