CodeGreen¶
-
Precise Energy Measurement
Hardware-level energy monitoring via Intel RAPL, NVIDIA NVML, and AMD ROCm with sub-millisecond resolution.
-
Multi-Language Support
Python, C, C++, and Java instrumentation via Tree-sitter with config-driven extensibility.
-
Interactive Visualization
Energy timeline plots with per-function breakdown, hotspot detection, and zoom/pan via Plotly.
-
Easy Integration
CLI tool with JSON/CSV/Markdown output, CI/CD energy gating via
--budget, and granularity control.
Setup & Installation¶
Quick start guide: installing and configuring CodeGreen.
What is CodeGreen?¶
CodeGreen is an energy measurement tool that helps developers understand the energy consumption of their software at the function level. It uses Tree-sitter AST parsing for automatic code instrumentation and a C++ backend (NEMB) for hardware-level energy readings with minimal overhead.
Key Features¶
- Energy Measurement: Per-function energy attribution via Intel RAPL, NVIDIA NVML, AMD ROCm
- Quick Measurement:
codegreen runmeasures energy of any shell command (like hyperfine for energy) - Code Analysis: Tree-sitter based static analysis across Python, C, C++, Java
- Visualization: Interactive energy timeline with
--export-plot(Plotly HTML with zoom/pan) - Granularity Control: Coarse mode (main only) or fine mode (all functions)
- CI/CD Energy Gating:
--budgetflag to enforce energy budgets in pipelines - Benchmarking: Built-in benchmark suite -- 0.03% error vs perf RAPL on representative workloads
Quick Start¶
Get started with CodeGreen in just a few steps:
Supported Platforms¶
-
Linux
Intel RAPL, NVIDIA NVML, and AMD ROCm/RAPL energy monitoring.
-
macOS
Apple Silicon and Intel Mac energy monitoring support.
-
Windows
Windows energy monitoring via supported hardware interfaces.
Hardware sensor availability varies by platform.
Citing CodeGreen¶
If you use CodeGreen in your research, please cite:
Rajput, S., Widmayer, T., Shang, Z., Kechagia, M., Sarro, F., & Sharma, T. (2024). Enhancing energy-awareness in deep learning through fine-grained energy measurement. ACM Transactions on Software Engineering and Methodology, 33(8), 1-34.
Community¶
- GitHub - Source code and issues
- Discussions - Community discussions
License¶
CodeGreen is released under the MPL 2.0 License. See the License page for details.