Abstract
AbstractDesign 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. This is 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 software written in Java and C++. In our results we observe energy consumption reductions greater than 7% in a Java-based textbook example when the pattern is implemented using reflective dispatch, and reductions of over 10% when experimenting with an open source Java 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. To explore the generalisability of our findings, we subsequently apply the same transformations to the C++ based CppParser. Total pattern removal here sees energy consumption reductions of over 66% while the reflective dispatch approach increases energy consumption by up to 2012%. Our results highlight the energy savings that can be achieved when the Visitor pattern is removed both in Java and C++ implementations, and also show that some language specific features can allow for further energy savings when the implementation of the pattern is varied.
Publisher
Springer Science and Business Media LLC
Cited by
1 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Understanding the Performance-Energy Tradeoffs of Object-Relational Mapping Frameworks;2024 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER);2024-03-12