Skip to content
Back to insights
Green Coding7 min read

The hidden cost of a loop: profiling for watts, not just milliseconds

Marta Ferraris

Principal Engineer · 19 February 2025

The hidden cost of a loop: profiling for watts, not just milliseconds

Green Coding sounds like a philosophy. In day-to-day engineering it is mostly profiling. The work that burns the most CPU cycles is the work that draws the most power, and finding it is a skill any team can build.

Faster usually means greener

When you cut the number of instructions to serve a request, you cut the energy to serve it. That is why a good flame graph is also a sustainability tool: the tall, wide frames are both your latency and your watts.

Where the waste hides

  • Chatty database access — the classic N+1
  • Serialisation of data nobody reads
  • Polling loops that could be events
  • Re-computing what a cache could hold

The cheapest, greenest instruction is the one you never execute.

Make it a budget, not a heroic sprint

One-off optimisation drives regress. We encode efficiency as budgets in CI — a request may not exceed a certain CPU-time or payload size — so the gains stick. Efficiency becomes a property of the codebase, not a quarterly campaign.

Marta Ferraris

Principal Engineer at Koent

Newsletter

Green software insights, monthly

Infrastructure tips, ESG updates, and engineering practices. One email per month.

No spam. Unsubscribe anytime.

Related posts

View all insights