---
title: "Tech Tip #10: Asking AI for efficient code works, until it doesn't"
description: "Asking AI for efficient code made it up to ninety-two percent more efficient."
url: https://greencode.ai/tech-tips/10-ai-code-ask-for-efficiency-then-check/
---

# Tech Tip #10: Asking AI for efficient code works, until it doesn't

**Asking AI for efficient code made it up to ninety-two percent more efficient.**

[Watch the video](https://media.greencode.ai/shorts/ai-code-ask-for-efficiency-then-check-06922f110f49.mp4)

Video created by [explainapaper.com](https://explainapaper.com/?utm_source=greencode.ai&utm_medium=film&utm_campaign=made-by)

### The problem

LLMs write code that passes tests but can be wasteful. GreenCode's EnergyBench found prompt changes can make generated code up to 91.9% more energy-efficient, but often at the cost of accuracy; in some cases removing half the problem description made code over four times more efficient while correctness dropped to zero.

### The fix you can use today

- Ask explicitly for efficient code and name the constraint (memory, allocations, complexity).
- Always run the tests: efficient-but-wrong is worth nothing.
- Measure the generated code's energy before you accept it.

GreenCode researchers found that asking AI for efficient code often helps, but not every time.

### Tools that help

- [EnergyBench](https://github.com/dragos-ionescu/energy-bench?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (GreenCode researchers): an MIT-licensed benchmark that scores LLM-generated code for correctness and for the energy it actually uses
- [GreenCode Constitution skill](https://greencode-constitution.org/?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (GreenCode researchers): open-source energy principles and a catalogue of 37 energy anti-patterns that an AI coding agent can follow to find and fix waste like this
- [green-languages](https://github.com/PLEnergyDev/green-languages?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (GreenCode researchers): a command-line tool that measures the energy of whole programs or marked sections of code, across languages

### How GreenCode helps

GreenCode helps tackle this by publishing EnergyBench, a benchmark that scores AI-written code for correctness and for the energy it uses. GreenCode also keeps its own AI lean, with small models and each request sent to the smallest capable component. [More on this](https://greencode.ai/feature/green-optimised-generative-ai/).

### Tags

#llm#ai-assistants#testing

### Sources

- [EnergyBench: Holistic Benchmark for Correct and Energy-Efficient LLM-Generated Code (FLTA 2025)](https://greencode.ai/publications/energybench-holistic-benchmark-for-correct-and-energy-efficient-llm-generated-co/)

[All GreenCode Tech Tips](https://greencode.ai/tech-tips/)

#### Key Facts

- Tip **#10**
- For **Developers**
- Category **AI and machine learning**
- Format **short video**
![GreenCode](https://greencode.ai/wp-content/uploads/2024/12/greencode-logo-website-small-colours-2.webp)

Want this checked on your own system? Talk to the GreenCode team.

[Get in touch](https://greencode.ai/contact/)
