---
title: "Tech Tip #3: Measure before and after, on the same setup"
description: "If you didn't measure it twice, you didn't save it."
url: https://greencode.ai/tech-tips/3-measure-before-and-after/
---

# Tech Tip #3: Measure before and after, on the same setup

**If you didn't measure it twice, you didn't save it.**

[Watch the video](https://media.greencode.ai/shorts/measure-before-and-after-f4f88e93ed01.mp4)

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

### The problem

Teams make code faster and call it greener, but speed and energy do not always move together. In GreenCode research, the GPU energy of a widely used AI inference engine fell by 4.7% while its speed rose by only 3%.

### The fix you can use today

- Measure energy before you change anything.
- Measure again after every change, on the same machines under the same load.
- Keep a change only if it saves energy and nothing else got worse.

GreenCode researchers measure each change before and after, and keep only the ones that save energy.

### Tools that help

- [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
- [GreenCode Constitution profiler (profile.sh)](https://greencode-constitution.org/skill.md?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (GreenCode researchers): a script from the Constitution tooling that measures the energy of a command from processor counters, GPU sensors and an optional smart plug, and writes the result as JSON
- [Scaphandre](https://github.com/hubblo-org/scaphandre?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode): measures the power drawn by each process on a Linux server and exports it to Prometheus and other monitoring stacks
- [CodeCarbon](https://github.com/mlco2/codecarbon?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode): a Python package that estimates the energy and CO2 of a run from hardware power and regional grid intensity
- [perf (RAPL counters)](https://perfwiki.github.io/main/?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode): Linux perf reads the processor's RAPL energy counters, e.g. `perf stat -e power/energy-pkg/`

### How GreenCode helps

GreenCode helps tackle this by measuring energy before any change and after every optimisation pass, on the same infrastructure under the same load. A saving only counts if quality, security and error rate did not get worse. [More on this](https://greencode.ai/feature/energy-and-cost-reduction/).

### Tags

#measurement#governance

### Sources

- [Reduced energy use (before and after, same infrastructure, same load)](https://greencode.ai/benefit/reduced-energy-use/)
- [GreenCode Constitution (Kapenekakis et al., GreenAI workshop, ECML PKDD 2026): 4.7% GPU energy on llama.cpp against a 3% speed gain; re-measure and keep only what saves](https://greencode.ai/publications/greencode-constitution-agent-principles-for-optimizing-code-and-llm-inference-en/)

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

#### Key Facts

- Tip **#3**
- For **CTOs and technical leads**
- Category **Measuring energy**
- 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/)
