A Developer-Oriented Framework for Assessing Power Consumption in Mobile Applications: Android Energy Smells Case Study
Abstract
:1. Introduction
- Energy code smell detection and refactorization;
- Power consumption signature before and after refactorization;
- Battery drain measurement in user-driven context;
- Results’ analysis: regression or improvement.
- RQ1: Which are the recommended battery characteristics to be analyzed in order to spot power consumption changes?
- RQ2: Is there a quantifiable correlation between energy code smells and power consumption for mobile applications?
- RQ3: Can the software power consumption signature be used to assess the quality of different versions of an application?
2. Related Work
3. Theoretical Background
3.1. Energy Code Smells
Listing 1. HashMap usage smell. |
HashMap<Integer, Object> map; void append(int id, Object object) { map.put(id, object); } |
Listing 2. Internal Getter/Setter smell. |
String firstName; String lastName; public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public String getFullName() { return getFirstName() + "," + getLastName(); } |
Listing 3. Member Ignoring Method smell. |
private getTimeDifference(Calendar pastDate) { Calendar today = Calendar.getInstance(); int difference = today.getTimeInMillis() - pastDate.getTimeInMillis(); return difference; } |
3.2. Energy Measurement
3.3. Power and Energy Signatures
- Application energy class or label;
- Power consumption regression testing;
- Energy efficient oriented development.
4. Experimental Setup
4.1. Measurement Methodology Definition
- Initial code base definition;
- Detection and correction of targeted code smells and application flavors;
- Battery measures collection during application runs;
- Measurements data extraction and processing;
- Overview of the proposed solution, as is shown in Figure 2.
Algorithm 1: Smell Correction and Flavor Generation |
abstract function PurgeSmells (baseApp, smell Set); Input: Initial code version baseApp, the catalog of code smells to be corrected smell Set Output: A appFlavor for each code smell contained in the catalog and base App flavor |
Algorithm 2. Power traces collection. |
abstract function RunAndMeasure (appFlavors, scenario); Input: The set of appFlavors to be executed given the user-driven scenario Output: Timestamped powerTraces for each flavor contained in appFlavors |
Algorithm 3. Power traces extraction. |
abstract function Extract (powerTraces); Input: The powerTraces data on which the extraction to be performed Output: An universal format csv File |
4.2. Applications under Analysis
4.3. Measurement Methodology
5. Experimental Results
5.1. Data Analysis
5.2. Battery Capacity
- All corrected versions were more energy efficient than the initial version.
- The differences between final capacities could be observed in terms of battery percentage shown in mobile device status bar.
- HMU code smell contributed the most to battery drainage.
- IGS code smell had the smallest contribution in overall consumption.
5.3. Charge Counter
- Corrected versions were more energy efficient, likewise capacity analysis, as shown previously.
- Charge counter traces provided a higher resolution in power consumption measurement and an opportunity to analyze short execution scenarios where capacity remained unchanged.
- Code smells power consumption trends were maintained as capacity analysis suggested.
- Charge counter accuracy enabled a more precise control of the scenario execution starting point.
- Maximum and minimum limit values provided information regarding battery health and physical capacity.
5.4. Battery Voltage
- Voltage characteristic was known to be nonlinear. However, analyzed data could give some useful hints on power consumption evolution.
- IGS was the only flavor which showed no improvement with regard to energy efficiency.
- Voltage trace analysis seemed to be more reliable in long execution test scenarios.
5.5. Current Consumption
- Instantaneous current analysis pointed out a slight energy improvement in the instant current characteristic.
- Both the analysis in question and the average current analysis indicated an energy efficiency regression when looking at VHMU flavor. However, when examining the bigger picture, the power consumption in VHMU had been seriously reduced. The first belief for this problem was that VHMU had a better execution time, but it was more resilient in terms of computational power.
6. Conclusions
- Short term:
- ○
- Charge counter;
- ○
- Average current;
- ○
- Instantaneous current;
- ○
- Energy counter.
- Long term:
- ○
- Charge counter;
- ○
- Capacity;
- ○
- Voltage.
- The accuracy and limitations of the battery fuel gauging system integrated in a mobile device;
- The invariance of battery properties in respect to close temperature environments;
- Lint static code analysis and manual correction.
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Schlachter, F. No Moore’s Law for Batteries. Proc. Natl. Acad. Sci. USA 2013, 110, 5273. [Google Scholar] [CrossRef]
- Time Mobility Poll Results. 2012. Available online: https://www.qualcomm.com/content/dam/qcomm-martech/dm-assets/documents/TimeMobilityPollResults.pdf (accessed on 2 January 2022).
- Hecht, G.; Benomar, O.; Rouvoy, R.; Moha, N.; Duchien, L. Tracking the software quality of android applications along their evolution (t). In Proceedings of the 30th IEEE/ACM International Conference on Automated Software Engineering (ASE), Lincoln, NE, USA, 9–13 November 2015; pp. 236–247. [Google Scholar]
- Vetro, A.; Ardito, L.; Procaccianti, G.; Morisio, M. Definition, implementation and validation of energy code smells: An exploratory study on an embedded system. In Proceedings of the ENERGY 2013: The 3rd International Conference on Smart Grids, Green Communications and IT Energy-Aware Technologies, Lisbon, Portugal, 24–29 March 2013; pp. 34–39. [Google Scholar]
- Zeller, A. The future of programming environments: Integration, synergy, and assistance. In Proceedings of the Future of Software Engineering (FOSE’07), Minneapolis, MN, USA, 23–25 May 2007; pp. 316–325. [Google Scholar]
- Carette, A.; Younes, M.A.A.; Hecht, G.; Moha, N.; Rouvoy, R. Investigating the energy impact of android smells. In Proceedings of the IEEE 24th International Conference on Software Analysis, Evolution and Reengineering (SANER), Taipa, Macao, 21–24 March 2017; pp. 115–126. [Google Scholar]
- Linares-Vásquez, M.; Bavota, G.; Bernal-Cárdenas, C.; Oliveto, R.; Di Penta, M.; Poshyvanyk, D. Mining energy-greedy api usage patterns in android apps: An empirical study. In Proceedings of the 11th Working Conference on Mining Software Repositories, Hyderabad, India, 31 May–1 June 2014; pp. 2–11. [Google Scholar]
- Pérez-Castillo, R.; Piattini, M. Analyzing the harmful effect of god class refactoring on power consumption. IEEE Softw. 2014, 31, 48–54. [Google Scholar] [CrossRef]
- Keong, C.K.; Wei, K.T.; Ghani, A.A.A.; Sharif, K.Y. Towards the Use of Software Product Metrics as an Indicator for Measuring Mobile Applications Power Consumption. Int. J. Comput. Inf. Eng. 2015, 9, 2325–2334. [Google Scholar]
- Litke, A.; Zotos, K.; Chatzigeorgiou, A.; Stephanides, G. Energy consumption analysis of design patterns. In Proceedings of the International Conference on Machine Learning and Software Engineering, St. Louis, MO, USA, 21–23 May 2005; pp. 86–90. [Google Scholar]
- Feitosa, D.; Ampatzoglou, A.; Avgeriou, P.; Chatzigeorgiou, A.; Nakagawa, E.Y. What can violations of good practices tell about the relationship between GoF patterns and run-time quality attributes? Inf. Softw. Technol. 2019, 105, 1–16. [Google Scholar] [CrossRef]
- Li, D.; Halfond, W.G. An investigation into energy-saving programming practices for android smartphone app development. In Proceedings of the 3rd International Workshop on Green and Sustainable Software, Hyderabad, India, 1 June 2014; pp. 46–53. [Google Scholar]
- Li, D.; Hao, S.; Halfond, W.G.; Govindan, R. Calculating source line level energy information for android applications. In Proceedings of the 2013 International Symposium on Software Testing and Analysis, Lugano, Switzerland, 15–20 July 2013; pp. 78–89. [Google Scholar]
- Li, T.; Xia, T.; Wang, H.; Tu, Z.; Tarkoma, S.; Han, Z.; Hui, P. Smartphone app usage analysis: Datasets, methods, and applications. IEEE Commun. Surv. Tutor. 2022, 24, 937–966. [Google Scholar] [CrossRef]
- Mundody, S.; Sudarshan, K. Evaluating the impact of android best practices on energy consumption. In Proceedings of the IJCA Proceedings on International Conference on Information and Communication Technologies, Bandung, Indonesia, 28–30 May 2014; Volume 8, pp. 1–4. [Google Scholar]
- Wilke, C.; Piechnick, C.; Richly, S.; Püschel, G.; Götz, S.; Aßmann, U. Comparing mobile applications’ energy consumption. In Proceedings of the 28th Annual ACM Symposium on Applied Computing, Coimbra, Portugal, 18–22 March 2013; pp. 1177–1179. [Google Scholar]
- Marcu, M.; Cernazanu, C. Dynamic analysis of electronic devices’ power signatures. In Proceedings of the 2012 IEEE International Instrumentation and Measurement Technology Conference Proceedings, Graz, Austria, 13–16 May 2012; pp. 117–122. [Google Scholar]
- Marcu, M.; Cernazanu, C. Applications of smart metering and home appliances’ power signatures. In Proceedings of the IEEE International Instrumentation and Measurement Technology Conference (I2MTC) Proceedings, Montevideo, Uruguay, 12–15 May 2014; pp. 331–335. [Google Scholar]
- Hecht, G.; Moha, N.; Rouvoy, R. An empirical study of the performance impacts of android code smells. In Proceedings of the International Conference on Mobile Software Engineering and Systems, Austin, TX, USA, 16–17 May 2016; pp. 59–69. [Google Scholar]
- Hort, M.; Kechagia, M.; Sarro, F.; Harman, M. A survey of performance optimization for mobile applications. IEEE Trans. Softw. Eng. 2021, 48, 2879–2904. [Google Scholar] [CrossRef]
- Android Performance Tips. Available online: https://developer.android.com/training/articles/perf-tips.html (accessed on 3 October 2024).
- Barsukov, Y. Challenges and Solutions in Battery Fuel Gauging; Texas Instruments, Inc.: Dallas, TX, USA, 2004. [Google Scholar]
- Balasingam, B.; Avvari, G.V.; Pattipati, K.R.; Bar-Shalom, Y. Performance analysis results of a battery fuel gauge algorithm at multiple temperatures. J. Power Sources 2015, 273, 742–753. [Google Scholar] [CrossRef]
- Hsu, C.H.; Combs, J.; Nazor, J.; Santiago, F.; Thysell, R.; Rivoire, S.; Poole, S.W. Application power signature analysis. In Proceedings of the 2014 IEEE International Parallel & Distributed Processing Symposium Workshops, Phoenix, AR, USA, 19–23 May 2014; pp. 782–789. [Google Scholar]
- Android Battery Api. Available online: https://source.android.com/devices/ tech/power/device (accessed on 22 January 2024).
- Scenario Testing Wiki. Available online: https://en.wikipedia.org/wiki/Scenario testing (accessed on 23 January 2024).
- Study Case Application Repository. Available online: https://github.com/claudiugroza/energysmells (accessed on 28 May 2017).
- Applications Analytics. Available online: https://hackernoon.com/how-much-time-do-people-spend-on-theirmobile-phones-in-2017-e5f90a0b10a6 (accessed on 22 May 2024).
- Battery Fuel Gauge Library. Available online: https://github.com/claudiugroza/batterygauge (accessed on 17 August 2017).
Code Version | Fixed Smell |
---|---|
V0 | - |
VHMU | HMU |
VIGS | IGS |
VMIM | MIM |
Vf | HMU, IGS, MIM |
API Constant | Description |
---|---|
BATTERY_PROPERTY_CHARGE_COUNTER | Remaining battery capacity in micro-ampere hour. |
BATTERY_PROPERTY_CURRENT_NOW | Instantaneous battery current consumption in microamperes. |
BATTERY_PROPERTY_CURRENT_AVERAGE | Average battery current in microamperes. |
BATTERY_PROPERTY_CAPACITY | Remaining battery capacity as an integer percentage. |
BATTERY_PROPERTY_ENERGY_COUNTER | Remaining energy in nanowatt-hours. |
BATTERY_PROPERTY_VOLTAGE | Voltage in millivolts. |
BATTERY_PROPERTY_TEMPERATURE | Temperature in degrees Celsius. |
Flavor | Dc [%] |
---|---|
VHMU | −27.27 |
VIGS | −9.09 |
VMIM | −18.18 |
Vf | −36.35 |
Flavor | Dcc [%] |
---|---|
VHMU | −25.25 |
VIGS | −2.94 |
VMIM | −14.94 |
Vf | −30.66 |
Flavor | Dv [%] |
---|---|
VHMU | −51.02 |
VIGS | +8.16 |
VMIM | −4.90 |
Vf | −31.84 |
Flavor | ACavg [mA] | ACmed [mA] |
---|---|---|
V0 | 959.6 | 970.5 |
VHMU | 974.2 | 981.1 |
VIGS | 952.7 | 958.5 |
VMIM | 981.9 | 989.6 |
Vf | 950.7 | 960.3 |
Flavor | ICavg [mA] | ICmed [mA] |
---|---|---|
V0 | 668.9 | 641.2 |
VHMU | 672.5 | 653.3 |
VIGS | 666.4 | 646.6 |
VMIM | 645.4 | 629.6 |
Vf | 657.5 | 634.9 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Groza, C.; Dumitru-Cristian, A.; Marcu, M.; Bogdan, R. A Developer-Oriented Framework for Assessing Power Consumption in Mobile Applications: Android Energy Smells Case Study. Sensors 2024, 24, 6469. https://doi.org/10.3390/s24196469
Groza C, Dumitru-Cristian A, Marcu M, Bogdan R. A Developer-Oriented Framework for Assessing Power Consumption in Mobile Applications: Android Energy Smells Case Study. Sensors. 2024; 24(19):6469. https://doi.org/10.3390/s24196469
Chicago/Turabian StyleGroza, Claudiu, Apostol Dumitru-Cristian, Marius Marcu, and Razvan Bogdan. 2024. "A Developer-Oriented Framework for Assessing Power Consumption in Mobile Applications: Android Energy Smells Case Study" Sensors 24, no. 19: 6469. https://doi.org/10.3390/s24196469
APA StyleGroza, C., Dumitru-Cristian, A., Marcu, M., & Bogdan, R. (2024). A Developer-Oriented Framework for Assessing Power Consumption in Mobile Applications: Android Energy Smells Case Study. Sensors, 24(19), 6469. https://doi.org/10.3390/s24196469