Green Code or Costly Code? Evaluating the Energy Costs of Iterative LLM-Based Code Optimizations
Not on the map. Why?
Abstract (arXiv)
Large Language Models (LLMs) are increasingly used to optimize code for performance. This practice often assumes that improvements in execution speed naturally translate into overall lower energy consumption. We challenge this assumption empirically by measuring whether performance-optimized code produced by LLM self-refinement pipelines is also energy-efficient relative to canonical human reference solutions, and whether the energy cost of the optimization process can be offset by subsequent execution-time savings. We evaluate 11 open-source models across four decoding configurations on all 1,000 problems of EffiBench, a state-of-the-art performance benchmark, while collecting per-process, hardware-level energy measurements throughout. Inference energy spans 0.79 to 8.68 MJ across model-variant pairs, which is roughly equivalent to the energy of 250 to 2800 GPT-4.1 queries. Limiting the maximum number of output tokens has the largest impact, reducing energy use by up to 69% compared to the default configuration. On the execution side, 42 of 44 configurations produce code that consumes more energy per problem than the canonical human reference, with overheads ranging from +4% to +886%. The two exceptions achieve only marginal gains, with break-even points on the order of 10^6 to 10^7 executions. Mixture-of-Experts architectures consume substantially less inference energy than equivalently-sized dense models without sacrificing correctness, making architectural choice a more consequential sustainability lever than decoding parameters. Performance optimization and energy efficiency are not always aligned goals: LLM self-refinement consistently produces faster-seeking but energy-heavier code relative to what a human engineer would write. All artifacts are available at https://doi.org/10.5281/zenodo.23598170.
Key facts. No citing papers in the map yet (data through 26 Nov 2026). Builds on 29 of its 36 references that are in the map. Submitted 23 Oct 2026.
Builds on
29 of 36 references.
References · 29
- 2025Qwen3 Technical Reportcited by 10,000
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 6,685
- 2024ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Toolscited by 1,191
- 2019Quantifying the Carbon Emissions of Machine Learningcited by 545
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 424
- 2022Estimating the Carbon Footprint of BLOOM, a 176B Parameter Language Modelcited by 273
- 2023Power Hungry Processing: Watts Driving the Cost of AI Deployment?cited by 206
- 2023Large Language Models for Software Engineering: Survey and Open Problemscited by 192
- 2023From Words to Watts: Benchmarking the Energy Costs of Large Language Model Inferencecited by 184
- 2026Ministral 3cited by 134
- 2025Nemotron 3 Nano: Open, Efficient Mixture-of-Experts Hybrid Mamba-Transformer Model for Agentic Reasoningcited by 127
- 2025How Hungry is AI? Benchmarking Energy, Water, and Carbon Footprint of LLM Inferencecited by 85
17 more
- 2023A Systematic Review of Green AIcited by 81
- 2024EffiBench: Benchmarking the Efficiency of Automatically Generated Codecited by 78
- 2022Eco2AI: carbon emissions tracking of machine learning models as the first step towards sustainable AIcited by 59
- 2025Nemotron-Cascade: Scaling Cascaded Reinforcement Learning for General-Purpose Reasoning Modelscited by 59
- 2024EffiLearner: Enhancing Efficiency of Generated Code via Self-Optimizationcited by 36
- 2023Greening Large Language Models of Codecited by 20
- 2025Towards Sustainable NLP: Insights from Benchmarking Inference Energy in Large Language Modelscited by 13
- 2025AI-Powered, But Power-Hungry? Energy Efficiency of LLM-Generated Codecited by 10
- 2025Generating Energy-Efficient Code via Large-Language Models -- Where are we now?cited by 9
- 2025Prompt engineering and its implications on the energy consumption of Large Language Modelscited by 6
- 2025Leveraging LLMs to Automate Energy-Aware Refactoring of Parallel Scientific Codescited by 6
- 2025Evaluating the Energy-Efficiency of the Code Generated by LLMscited by 6
- 2025Comparative Analysis of Carbon Footprint in Manual vs. LLM-Assisted Code Developmentcited by 5
- 2025GREEN-CODE: Learning to Optimize Energy Efficiency in LLM-based Code Generationcited by 4
- 2025Toward Green Code: Prompting Small Language Models for Energy-Efficient Code Generationcited by 3
- 2025Can We Make Code Green? Understanding Trade-Offs in LLMs vs. Human Code Optimizationscited by 2
- 2025METRION: A Framework for Accurate Software Energy Measurementcited by 1
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026Understanding Efficiency: Quantization, Batching, and Serving Strategies in LLM Energy Use
- 2026Beyond FLOPs: Energy-Aware Knowledge Distillation for Sustainable LLMs on Code-Related Task
- 2025The Energy Cost of Reasoning: Analyzing Energy Usage in LLMs with Test-time Compute
- 2026Efficiency Hallucination: Formalizing and Measuring Behavioral Calibration in LLM-Based Code Optimization
- 2026Evaluating the Environmental Impact of using SLMs and Prompt Engineering for Code Generation ↗
- 2026Characterizing Performance-Energy Trade-offs of Large Language Models in Multi-Request Workflows
- 2026Pattern-Driven Evaluation of LLM Code Optimization: Isolating Compiler-Transcendent Semantic Reasoning
- 2024Should AI Optimize Your Code? A Comparative Study of Classical Optimizing Compilers Versus Current Large Language Models