Resources

  1. Install CodeGreen CLI Tool
  2. GitHub Repository
  3. Documentation & Guides
  4. FSE 2026 Preprint
  5. TOSEM Preprint (Foundational Paper)

What is CodeGreen?

CodeGreen tells you how much energy your code uses, down to individual functions. You install it (pip install codegreen), point it at your script (codegreen run your_script.py), and it gives you a breakdown of where the energy went.

Under the hood it uses Tree-sitter to parse your code’s AST and automatically instruments it, then a C++ backend (NEMB) reads hardware-level energy counters. The error margin is about 0.03% compared to perf RAPL on our benchmarks.

What it supports

Languages: Python, C, C++, Java (via Tree-sitter, so adding more is straightforward)

Platforms:

  • Linux: Intel RAPL, NVIDIA NVML, AMD ROCm
  • macOS: Apple Silicon via IOReport (CPU, GPU, ANE, DRAM)
  • Windows 11: RAPL via the EMI driver (no extra install needed)

Output: JSON, CSV, or Markdown. Also generates interactive Plotly plots with energy timelines and hotspot detection.

For CI/CD, there’s a --budget flag that fails the build if energy exceeds a threshold.

Quick Start

pip install codegreen
codegreen run <your_script>

Background

CodeGreen grew out of our earlier work on energy profiling TensorFlow APIs, where we profiled 1,284 API calls. Greenlight was framework-specific; CodeGreen generalizes the same idea to any codebase, any language, any platform.

For detailed documentation, usage examples, and the latest updates, check the CodeGreen project website.