TitleThe Energy Cost of the Visitor Pattern
Publication TypeConference Paper
Year of Publication2022
AuthorsBree D., Cinnéide M.Ó
Conference Name2022 IEEE International Conference on Software Maintenance and Evolution (ICSME)
Date Publishedoct
PublisherIEEE Computer Society
Conference LocationLos Alamitos, CA, USA
Keywordscasting, costs, energy consumption, Libraries, Programming, software algorithms, Software maintenance
Abstract

Design patterns are applied frequently during software evolution in order to make the software more flexible and amenable to extension. One little-studied aspect of design patterns is their propensity to increase run time energy consumption due to the indirection and additional structure they introduce. In this paper we study the impact of the Visitor pattern on energy efficiency. The Visitor pattern separates an algorithm from the objects it acts upon and improves maintainability by placing each algorithm within a single visitor class, at the cost of increased indirection due to the double dispatch required when the algorithm is invoked. We experimentally investigate the energy impact of varying the implementation of this pattern, and of removing the pattern entirely from the software. In our results we observe energy consumption reductions of greater than 7% in the textbook example when the pattern is implemented using reflective casting, and reductions of over 10% when experimenting with an open source project, JavaParser. The complete removal of the pattern yields more complex results, with little impact in the textbook example but reductions of over 7% in the JavaParser study. Our results highlight the energy savings that may be achieved when the Visitor pattern is removed, and show that energy savings may also be achieved by varying the implementation of the pattern.

URLhttps://doi.ieeecomputersociety.org/10.1109/ICSME55016.2022.00036
DOI10.1109/ICSME55016.2022.00036