Abstract
A map is a data structure that is commonly used to store data as key–value pairs and retrieve data as keys, values, or key–value pairs. Although Java offers different map implementation classes, Android SDK offers other implementations supposed to be more efficient than HashMap: ArrayMap and SparseArray variants (SparseArray, LongSparseArray, SparseIntArray, SparseLongArray, and SparseBooleanArray). Yet, the performance of these implementations in terms of CPU time, memory usage, and energy consumption is lacking in the official Android documentation; although saving CPU, memory, and energy is a major concern of users wanting to increase battery life. Consequently, we study the use of map implementations by Android developers in two ways. First, we perform an observational study of 5713 Android apps in GitHub. Second, we conduct a survey to assess developers’ perspective on Java and Android map implementations. Then, we perform an experimental study comparing HashMap, ArrayMap, and SparseArray variants map implementations in terms of CPU time, memory usage, and energy consumption. We conclude with guidelines for choosing among the map implementations: HashMap is preferable over ArrayMap to improve energy efficiency of apps, and SparseArray variants should be used instead of HashMap and ArrayMap when keys are primitive types.
Similar content being viewed by others
Notes
The mobile phone has to be rooted first.
References
Banerjee A, Chong LK, Chattopadhyay S, Roychoudhury A (2014) Detecting energy bugs and hotspots in mobile apps. In: Proceedings of the 22nd ACM SIGSOFT international symposium on foundations of software engineering, FSE, vol 2014. ACM, New York, pp 588–598. https://doi.org/10.1145/2635868.2635871
Chen X, Zong Z (2016) Android app energy efficiency: the impact of language, runtime, compiler, and implementation. In: 2016 IEEE international conferences on big data and cloud computing (BDCloud), social computing and networking (socialcom), sustainable computing and communications (sustaincom) (BDCloud-socialcom-sustaincom), pp 485–492. https://doi.org/10.1109/BDCloud-SocialCom-SustainCom.2016.77
Cuervo E, Balasubramanian A, Dk Cho, Wolman A, Saroiu S, Chandra R, Bahl P (2010) MAUI: making Smartphones last longer with code offload. In: Proceedings of the 8th international conference on mobile systems, applications, and services, MobiSys ’10. ACM, New York, pp 49–62. https://doi.org/10.1145/1814433.1814441
Gui J, Mcilroy S, Nagappan M, Halfond WGJ (2015) Truth in advertising: the hidden cost of mobile ads for software developers. In: Proceedings of the 37th international conference on software engineering (ICSE)
Hasan S, King Z, Hafiz M, Sayagh M, Adams B, Hindle A (2016) Energy profiles of java collections classes. In: Proceedings of the 38th international conference on software engineering (ICSE), Austin, TX, US, pp 225–236
Huang P, Xu T, Jin X, Zhou Y (2016) Defdroid: towards a more defensive mobile OS against disruptive app behavior. In: Proceedings of the the 14th ACM international conference on mobile systems, applications, and services, singapore, singapore. https://doi.org/10.1145/2906388.2906419
Li D, Hao S, Gui J, Halfond WGJ (2014) An empirical study of the energy consumption of android applications. In: Proceedings of the international conference on software maintenance and evolution (ICSME)
Linares-Vásquez M, Bavota G, Bernal-Cárdenas C, Oliveto R, Di Penta M, Poshyvanyk D (2014) Mining energy-greedy API usage patterns in android apps: an empirical study. In: Proceedings of the 11th working conference on mining software repositories, MSR 2014. ACM, New York, pp 2–11. https://doi.org/10.1145/2597073.2597085
Liu K, Pinto G, Liu YD (2015) Data-oriented characterization of application-Level energy optimization. In: Egyed A, Schaefer I (eds) Fundamental approaches to software engineering: 18th international conference, FASE 2015, held as part of the european joint conferences on theory and practice of software, ETAPS 2015, London, UK, April 11–18, 2015, Proceedings. Springer, Berlin, pp 316–331. https://doi.org/10.1007/978-3-662-46675-9_21
Manotas I, Pollock L, Clause J (2014) SEEDS: a software engineer’s energy-optimization decision support framework. In: Proceedings of the 36th international conference on software engineering, ICSE, vol 2014. ACM, New York, pp 503–514. https://doi.org/10.1145/2568225.2568297
Morales R, Saborido R, Khomh F, Chicano F, Antoniol G (2017) Earmo: an energy-aware refactoring approach for mobile apps. IEEE Trans Softw Eng PP (99):1–1. https://doi.org/10.1109/TSE.2017.2757486
Saborido R, Beltrame G, Khomh F, Alba E, Antoniol G (2016) Optimizing user experience in choosing android applications. In: Proceedings of the 23rd IEEE international conference on software analysis, evolution, and reengineering (SANER)
Saborido R, Khomh F, Antoniol G, Guéhéneuc YG (2017) Comprehension Of ads-supported and paid Android applications: are they different?. In: Proceedings of the 25th international conference on program comprehension (ICPC). IEEE, Buenos Aires, pp 143–153. https://doi.org/10.1109/ICPC.2017.25
Sahin C, Tornquist P, Mckenna R, Pearson Z, Clause J (2014) How does code obfuscation impact energy usage?. In: ICSME’14, pp 131–140
Sahin C, Pollock L, Clause J (2016) From benchmarks to real apps: exploring the energy impacts of performance-directed changes. J Syst Softw. https://doi.org/10.1016/j.jss.2016.03.031. http://www.sciencedirect.com/science/article/pii/S0164121216000893
Shacham O, Vechev M, Yahav E (2009) Chameleon: adaptive selection of collections. SIGPLAN Not 44(6):408–418. https://doi.org/10.1145/1543135.1542522
Singer J, Sim SE, Lethbridge TC (2008) Software engineering data collection for field studies. In: Guide to advanced empirical software engineering. Springer, pp 9–34
Tyagi PK (1989) The effects of appeals, anonymity, and feedback on mail survey response patterns from salespeople. J Acad Mark Sci 17(3):235–241. https://doi.org/10.1007/bf02729815
Zhang C, Hindle A, German DM (2014) The impact of user choice on energy consumption. IEEE Softw 31(3):69–75. https://doi.org/10.1109/MS.2014.27
Author information
Authors and Affiliations
Corresponding author
Additional information
Communicated by: Daniel Amyot
Rights and permissions
About this article
Cite this article
Saborido, R., Morales, R., Khomh, F. et al. Getting the most from map data structures in Android. Empir Software Eng 23, 2829–2864 (2018). https://doi.org/10.1007/s10664-018-9607-8
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10664-018-9607-8