mlsanityData to 14 Oct 2026

Can We Make Code Green? Understanding Trade-Offs in LLMs vs. Human Code Optimizations

arXiv 2503.20126 ↗First posted 26 Mar 2025cs.SE cs.AI cs.PFcited by 1

Not on the map. Why?

Abstract (arXiv)

The rapid technological evolution has accelerated software development for various domains and use cases, contributing to a growing share of global carbon emissions. While recent large language models (LLMs) claim to assist developers in optimizing code for performance and energy efficiency, their efficacy in real-world scenarios remains under exploration. In this work, we explore the effectiveness of LLMs in reducing the environmental footprint of real-world projects, focusing on software written in Matlab-widely used in both academia and industry for scientific and engineering applications. We analyze energy-focused optimization on 400 scripts across 100 top GitHub repositories. We examine potential 2,176 optimizations recommended by leading LLMs, such as GPT-3, GPT-4, Llama, and Mixtral, and a senior Matlab developer, on energy consumption, memory usage, execution time consumption, and code correctness. The developer serves as a real-world baseline for comparing typical human and LLM-generated optimizations. Mapping these optimizations to 13 high-level themes, we found that LLMs propose a broad spectrum of improvements--beyond energy efficiency--including improving code readability and maintainability, memory management, error handling while the developer overlooked some parallel processing, error handling etc. However, our statistical tests reveal that the energy-focused optimizations unexpectedly negatively impacted memory usage, with no clear benefits regarding execution time or energy consumption. Our qualitative analysis of energy-time trade-offs revealed that some themes, such as vectorization preallocation, were among the common themes shaping these trade-offs. With LLMs becoming ubiquitous in modern software development, our study serves as a call to action: prioritizing the evaluation of common coding practices to identify the green ones.

Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Builds on 17 of its 80 references that are in the map. First posted on arXiv 26 Mar 2025.

Builds on

17 of 80 references.

References · 17

  1. 2023GPT-4 Technical Reportcited by 18,396
  2. 2019Quantifying the Carbon Emissions of Machine Learningcited by 521
  3. 2023Supersonic: Learning to Generate Source Code Optimizations in C/C++cited by 16
  4. 2023Analysis of ChatGPT on Source Codecited by 12
  5. 2023Efficiency is Not Enough: A Critical Perspective of Environmentally Sustainable AIcited by 12
  6. 2019Catalog of Energy Patterns for Mobile Applicationscited by 8
  7. 2024A Controlled Experiment on the Energy Efficiency of the Source Code Generated by Code Llamacited by 8
  8. 2023EnergiBridge: Empowering Software Sustainability through Cross-Platform Energy Measurementcited by 6
  9. 2024Can Open-Source LLMs Compete with Commercial Models? Exploring the Few-Shot Performance of Current GPT Models in Biomedical Taskscited by 6
  10. 2024Generating Energy-efficient code with LLMscited by 4
  11. 2024Unveiling the Energy Vampires: A Methodology for Debugging Software Energy Consumptioncited by 4
  12. 2019Do Energy-oriented Changes Hinder Maintainability?cited by 3
5 more
  1. 2023A Case for Sustainability and Environment Friendliness in Software Development and Architecture Decisions by Taking Energy-Efficient Design Decisionscited by 3
  2. 2023LLM Interactive Optimization of Open Source Python Libraries -- Case Studies and Generalizationcited by 3
  3. 2022SLNET: A Redistributable Corpus of 3rd-party Simulink Modelscited by 2
  4. 2022On the Energy Consumption of Different Dataframe Processing Libraries -- An Exploratory Studycited by 2
  5. 2024Energy Patterns for Web: An Exploratory Studycited by 1

Built on by

Cited by year

Citing papers per year: 2025: 1.

1 paper.