Organizations: University at Buffalo, Buffalo, NY, USA · National Center for Supercomputing Applications, Urbana, IL, USA · IBM Research, Yorktown Heights, NY, USA
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 57% for Granite-4.0-H-Small and 6.4% 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.
Figures & tables
Model Details
Model Configuration
Model Name
Model Weights
Knowledge Cut-off
API Provider
API Type Used
Temp.
Top_p
Top_k
Reasoning / Thinking Configuration
Claude 4.5 Haiku
Closed
Feb. 2025
Anthropic
Batch
∗ 1
∗ 1
∗ 0
∗ Thinking: Disabled
Gemini 3.8 Flash
Closed
Mar. 2026
Google Vertex AI
Batch
N/A
N/A
N/A
∗ Thinking Level: Medium
GPT-5.6 Terra
Closed
Feb. 2026
OpenAI
Batch
N/A
N/A
N/A
∗ Reasoning Effort: Medium
GPT-OSS-120B (116.8B total / 5.1B active)
Open
Jun. 2024
Fireworks AI
Batch
1
1
∗ 0
Reasoning Effort: High
Gemma 4 26B A4B IT (25.2B total / 3.8B active)
Open
Jan. 2026
Fireworks AI
Batch
1
0.95
64
Thinking: Enabled
TABLE I : Overview of the LLMs under study along with their respective configurations used for the study. An asterisk ( ∗ ) indicates the default value used by the model provider, while N/A denotes a configuration that is not applicable to the model.
Fig. 1 : Code generation workflow applied to each prompting strategy across both evaluation stages.
Fig. 2 : Code evaluation workflow for the generated Python and C++ programs.
Fig. 3 : Fine-grained energy measurement process for Python and C++ programs.
Fig. 4 : EffiBench prompt structure used as the baseline.
Prompt Number
Conversation Type
Source
Prompt Type
Change Scope
Additions Made to EffiBench Prompt
⋆ Prompt 0 (EffiBench Prompt)
SingleTurn
[ 14 ]
Zero-Shot
-
-
Prompt 1
SingleTurn
[ 11 ] [ 13 ] [ 27 ] [ 28 ]
Zero-Shot
User Prompt
Energy-Efficiency Keyword
Prompt 2
Single-Turn
-
Zero-Shot
User Prompt
Energy-Efficiency Keyword and Definition
Prompt 3
Single-Turn
-
Few-Shot
User Prompt
Energy-Efficiency Keyword, General Efficiency Guidelines
⋆ Prompt 4
Single-Turn
-
Persona-Based + Zero-Shot
User Prompt
General Efficiency Guidelines, Language-Specific Efficient Practices
TABLE II : Summary of 21 prompting strategies and the EffiBench prompt evaluated in the initial analysis. Strategies marked with ⋆ and highlighted in green were selected for the final evaluation for Python and C++ code generation across our extended EffiBench dataset and all LLMs under evaluation.
Fig. 5 : Finalized prompting strategies for Python and C++ code generation. The top panel presents the five single-turn prompting strategies, while the bottom panel presents the three multi-turn prompting strategies. Both are applied across the extended EffiBench dataset and evaluated across all LLMs under study.
Fig. 6 : Average change in energy consumption relative to the baseline prompt across 110 python problems and 21 prompting strategies, aggregated across the 3 LLMs evaluated in the initial analysis.
Algorithms
Difficulty
Backtracking
BFS
Binary Search
Bit Manip.
DFS
Divide & Conquer
DP
Greedy
Sliding Window
Sorting
Two Pointers
Total
Easy
1
0
13
21
0
2
7
25
7
47
24
110
Medium
17
21
48
33
24
3
96
98
31
83
33
333
Hard
3
6
24
7
2
4
45
18
8
17
0
94
Total
21
27
85
61
26
9
148
141
46
147
57
537
TABLE III : Distribution of benchmark problems solved by all 10 evaluated LLMs across difficulty levels and algorithm categories for Python code generation.
Fig. 7 : Average percentage energy reduction achieved by the 8 prompting strategies relative to the baseline prompt for Python code generation. Negative values indicate lower energy consumption than the baseline prompt.
Fig. 8 : Impact of prompting strategies on the energy consumption of Python code generation relative to the baseline prompt across problem difficulty levels and algorithmic categories, aggregated across all evaluated models.
Algorithms
Difficulty
Backtracking
BFS
Binary Search
Bit Manip.
DFS
Divide & Conquer
DP
Greedy
Sliding Window
Sorting
Two Pointers
Total
Easy
1
0
20
19
0
1
5
31
4
56
26
121
Medium
9
9
55
40
13
3
105
132
37
97
43
373
Hard
0
7
22
11
2
1
66
15
8
21
1
113
Total
10
16
97
70
15
5
176
178
49
174
70
607
TABLE IV : Distribution of benchmark problems solved by all 10 evaluated LLMs across difficulty levels and algorithm categories for C++ code generation.
Fig. 9 : Average percentage energy reduction achieved by the 8 prompting strategies relative to the baseline prompt for C++ code generation. Negative values indicate lower energy consumption than the baseline.
Fig. 10 : Impact of prompting strategies on the energy consumption of C++ code generation relative to the baseline prompt across problem difficulty levels and algorithmic categories, aggregated across all evaluated models.
Fig. 11 : Overall impact of 8 prompting strategies Python and C++ code generation for their respective evaluation datasets aggregated across all models.