🤖 AI Summary
This work addresses the limitation of existing energy profiling tools, which only support coarse-grained runtime evaluation and cannot provide fine-grained energy estimates for code constructs—such as functions or loops—during the design phase. To bridge this gap, we propose EnCoDe, the first method enabling block-level energy estimation at design time. EnCoDe leverages PowerLens, a custom-built high-precision measurement tool that captures sub-millisecond energy traces, and combines them with static code features—including structural properties, complexity, density, and contextual information—to train machine learning models that predict energy consumption and identify energy hotspots. Using a novel dataset of over 18,000 Python programs annotated at the code-block level, our regression model achieves an R² of 0.75, and hotspot classification accuracy reaches 80.6%, enabling stable, execution-free, fine-grained energy analysis.
📝 Abstract
Energy efficiency has emerged as a vital attribute of software quality, with significant implications for both environmental sustainability and operational costs. However, existing profiling tools operate only at runtime and coarse granularity, typically capturing energy at the process or method level. Such tools fail to expose how small code blocks, such as functions, loops, and conditionals, contribute to energy consumption, preventing developers from reasoning about and comparing the energy efficiency of programming constructs during design-time. To address this gap, we propose EnCoDe, a methodology for fine-grained, design-time energy estimation, with the following key contributions: (1) PowerLens, a novel measurement methodology that achieves reliable sub-millisecond energy readings for small code blocks; (2) Extensive empirical study on code blocks extracted from over 18,000 Python programs, uncovering linear and non-linear relationships between energy consumption and static code features such as structural, complexity, density, and contextual characteristics, resulting in a first-of-its-kind fine-grained dataset; and (3) Predictive modeling, in which machine learning models are trained on these features to accurately estimate and classify block-level energy consumption at design-time. Our results demonstrate stable, reproducible block-level estimations, with regressors achieving R^2 = 0.75 and classifiers achieving 80.6% accuracy in identifying energy hotspots, enabling developers to localize and address inefficient code regions early in the development process without execution.