CPPJoules: An Energy Measurement Tool for C++
Shivadharshan S, Akilesh P, Rajrupa Chattaraj, Sridhar Chimalakonda
TL;DR
CPPJoules addresses the lack of C++ energy measurement tools by building on Intel RAPL and NVML to measure energy usage during C++ snippet execution. The tool provides a cross-platform energy-tracking backend with a clear execution flow and library integration, using Linux powercap and Windows intel-power-gadget, with optional GPU measurement. Evaluation against a Python-based baseline (pyJoules) on Rosetta Code tasks shows comparable energy and runtime patterns, supported by Wilcoxon tests. The work highlights the need for language-specific energy profiling and opens avenues to study energy efficiency in C++ libraries and frameworks.
Abstract
With the increasing complexity of modern software and the demand for high performance, energy consumption has become a critical factor for developers and researchers. While much of the research community is focused on evaluating the energy consumption of machine learning and artificial intelligence systems -- often implemented in Python -- there is a gap when it comes to tools and frameworks for measuring energy usage in other programming languages. C++, in particular, remains a foundational language for a wide range of software applications, from game development to parallel programming frameworks, yet lacks dedicated energy measurement solutions. To address this, we have developed CPPJoules, a tool built on top of Intel-RAPL to measure the energy consumption of C++ code snippets. We have evaluated the tool by measuring the energy consumption of the standard computational tasks from the Rosetta Code repository. The demonstration of the tool is available at \url{https://www.youtube.com/watch?v=GZXYF3AKzPk} and related artifacts at \url{https://rishalab.github.io/CPPJoules/}.
