Abstract

As AI-assisted programming becomes increasingly mainstream, the environmental impact of AI-generated software has emerged as an important consideration. This motivates evaluating LLM-generated code beyond functional correctness by considering execution efficiency and energy consumption. However, despite substantial advances in code generation, frontier LLMs are rarely evaluated based on the energy efficiency of the code they produce. In this work, we conduct a comprehensive evaluation of 21 prompting strategies for energy-efficient code generation and identify 8 strategies for evaluation across 10 widely used open-weight and proprietary LLMs. We evaluate their effectiveness for both Python and C++ code generation relative to a baseline prompt. Across the evaluated models, the selected prompting strategies achieved energy reductions of up to 25% for Python and 17% for C++ code generation. At the model level, Python energy reductions reached up to 50% for Granite-4.0-H-Small, 39% for Claude 4.5 Haiku, and 28% for MiniMax M3, while C++ reductions reached up to 56% for Granite-4.0-H-Small and 7% for Qwen3-Coder-480B-A35B-Instruct. These results demonstrate that prompting strategies can substantially influence the energy consumption of LLM-generated code, although their effectiveness varies across models and programming languages. Our findings highlight the importance of incorporating energy efficiency into the evaluation and optimization of LLM-based code generation and provide practical insights into designing prompts for more sustainable AI-assisted programming.

Keywords

Subject

Publication details

Journal
Not available
Open access
Green open access

Cite this article

APA 7

Rekhi, R., Zhang, B., Islam, M. A., Pasham, J. K., Chitturi, Y., Paramesha, A., Valiveti, I., Imran, A., Turkkan, B., & Kosar, T. (2026). Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting. https://omanscience.com/en/articles/improving-the-energy-efficiency-of-the-code-generated-by-llms-through-effective-prompting

MLA 9

Rekhi, Ritika, et al. "Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting." https://omanscience.com/en/articles/improving-the-energy-efficiency-of-the-code-generated-by-llms-through-effective-prompting.

Chicago (author–date)

Rekhi, Ritika, Bing Zhang, Md Arman Islam, Jaya Krishna Pasham, Yeswanth Chitturi, Akshay Paramesha, Isha Valiveti, Asif Imran, Bekir Turkkan, and Tevfik Kosar. 2026. "Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting." https://omanscience.com/en/articles/improving-the-energy-efficiency-of-the-code-generated-by-llms-through-effective-prompting.

Harvard

Rekhi, R., Zhang, B., Islam, M. A., Pasham, J. K., Chitturi, Y., Paramesha, A., Valiveti, I., Imran, A., Turkkan, B. and Kosar, T. (2026) 'Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting', Available at: https://omanscience.com/en/articles/improving-the-energy-efficiency-of-the-code-generated-by-llms-through-effective-prompting.

Vancouver

Rekhi R, Zhang B, Islam MA, Pasham JK, Chitturi Y, Paramesha A, et al. Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting. https://omanscience.com/en/articles/improving-the-energy-efficiency-of-the-code-generated-by-llms-through-effective-prompting

IEEE

R. Rekhi, B. Zhang, M. A. Islam, J. K. Pasham, Y. Chitturi, A. Paramesha, I. Valiveti, A. Imran, B. Turkkan, and T. Kosar, "Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting," https://omanscience.com/en/articles/improving-the-energy-efficiency-of-the-code-generated-by-llms-through-effective-prompting.