AI
LLM-optimized code runs faster but guzzles energy, study finds
Research reveals a troubling tradeoff: code improved by AI models prioritizes speed over efficiency, often consuming far more energy than human-written alternatives.
When software engineers use large language models to optimize code, they typically expect gains in both performance and energy efficiency. A new study challenges that assumption, showing that AI-refined code often trades sustainability for raw speed—and the energy cost of running the optimization process itself may never pay off.
The Study Setup#
Researchers tested 11 open-source LLMs across four decoding strategies on all 1,000 problems in EffiBench, a comprehensive performance benchmark. They carefully measured hardware-level energy consumption throughout both the inference process and the execution of the resulting code. This approach captured the full energy picture: both what the model burned while generating optimizations and what the optimized code then consumed in production.
High Inference Costs#
The energy required just to run the optimization process proved substantial. Inference energy ranged from 0.47 to 6.50 megajoules across different model variants—roughly equivalent to between 150 and 2,100 queries to GPT-4.1. A simple change in decoding strategy—limiting the maximum number of tokens the model outputs—proved surprisingly effective, cutting energy use by up to 72% without harming results.
Code That Burns More Energy#
On the execution side, the findings were more striking. Of 44 model configurations tested, 38 produced code that consumed more energy per problem than hand-written reference implementations. Energy overheads ranged from 6% to 638%. Only six configurations managed to beat human baselines, and even those gains were marginal. To break even on the energy invested in optimization, the resulting code would need to run roughly 200,000 times per problem—a threshold most real-world applications never reach.
Architectural Lessons#
Not all models performed equally. Mixture-of-Experts architectures consumed substantially less inference energy than dense models of equivalent size, without sacrificing correctness. This suggests that architectural choices matter more for sustainability than tuning decoding parameters, offering a clearer path forward for more efficient AI-driven optimization.
The Speed-Efficiency Mismatch#
The core insight is uncomfortable: performance optimization and energy efficiency are not always aligned. LLM self-refinement pipelines reliably produce code that chases faster execution times while ignoring the energy footprint. The result is code that runs quicker but costs more—a tradeoff that matters as data centers and device power consumption become central to computing's environmental and economic impact.

