跳到正文
arXiv cs.AI· Sadra Emami, Benjamin Weigell, Mohammad Reza Mousavi, Gunel Jahangirova, Hugo Araujo, Bernhard Bauer·· 12 小时前AI 评分38

绿色代码还是昂贵代码?评估基于 LLM 迭代代码优化的能源成本

Green Code or Costly Code? Evaluating the Energy Costs of Iterative LLM-Based Code Optimizations

AI 导读

研究实测发现,LLM 自迭代优化产出的代码虽追求更快执行,却比人类参考方案更耗能:44 种配置中有 42 种单题能耗高出 +4% 至 +886%,仅两种实现微弱收益,且需 10^6 至 10^7 次执行才能回本。

正文 · 原文

View PDF HTML (experimental)

Abstract: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 this https URL.
Comments: Accepted at the 49th IEEE/ACM International Conference on Software Engineering (ICSE 2027)
Subjects: Software Engineering (cs.SE); Artificial Intelligence (cs.AI)
Cite as: arXiv:2610.32891 [cs.SE]
  (or arXiv:2610.32891v1 [cs.SE] for this version)
  https://doi.org/10.48550/arXiv.2610.32891

arXiv-issued DOI via DataCite (pending registration)

Submission history

From: Sadra Emami [view email]
[v1] Fri, 23 Oct 2026 16:58:01 UTC (160 KB)

来源:arXiv cs.AI · arxiv.org