Javascript must be enabled for the correct page display

AI Code Optimization for Sustainability

Mojmír, Majer (2026) AI Code Optimization for Sustainability. Master's Thesis / Essay, Computing Science.

[img]
Preview
Text
MScThesisTNOAICodeOptimizationforSustainability-1.pdf

Download (3MB) | Preview

Abstract

The energy consumption of software is a growing concern in software engineering. While Language Models (LMs) are increasingly used for code generation, their ability to refactor existing code specifically for reducing its energy consumption remains under-explored. This study investigates the relationship between model size and inference strategies on the performance of Python code rewritten by LMs, as well as the ability to predict this performance using Machine Learning (ML) models trained on static code analysis metrics. We consolidate three datasets, creating more than 14, 000 refactored variants using six Qwen3 models and four inference strategies from 1, 763 original Python function implementations. We analyze functional correctness and energy consumption in a controlled environment using a custom metric: Relative Energy Impact (REI). Our results show that both functional correctness and REI scale log-linearly with model size, with Qwen3 32B providing the largest overall code energy savings. Inference strategies affect energy consumption only when used in tandem with a specific model size. Furthermore, ML models are better able to predict functional correctness (F1 = 0.82) compared to energy savings (F1 = 0.59). We find that the inherent inefficiency of the baseline code sample is the primary determinant of potential energy savings, yet our prediction models struggle to identify it. Furthermore, LMs used for refactoring implement well-known space and time complexity reductions but cannot further improve the energy efficiency of code. Consequently, research should move toward the identification of energy-inefficient hot-spots in code to prevent unnecessary refactoring of already efficient implementations and toward improving the ability of LMs to understand the energy efficiency of code.

Item Type: Thesis (Master's Thesis / Essay)
Supervisor name: Feitosa, D. and Andrikopoulos, V.
Degree programme: Computing Science
Thesis type: Master's Thesis / Essay
Language: English
Date Deposited: 17 Feb 2026 10:00
Last Modified: 17 Feb 2026 10:00
URI: https://fse.studenttheses.ub.rug.nl/id/eprint/37235

Actions (login required)

View Item View Item