NetGreener — Energy & Carbon Profiler for Python
Measure, analyze, and reduce the energy consumption and carbon footprint of your Python code — without leaving VS Code.
What it does
NetGreener connects your editor to the NetGreener platform, giving you:
- Live energy metrics — CPU, GPU, and memory power draw for every run, shown in the sidebar
- Code issue detection — static analysis that flags energy-inefficient patterns (redundant loops, excessive allocations, repeated I/O, and more) directly in your editor
- One-click LLM optimization — select any flagged function and get a fully rewritten, energy-efficient version with an explanation
- Carbon estimates — project-level CO₂ estimates based on your run history and infrastructure
- Insights — trends and recommendations across all your projects
Requirements
The extension requires the NetGreener CLI (netgreener) to measure and analyze your code.
If the CLI is not installed when the extension activates, you will be prompted automatically:
- Install with pipx (recommended) — installs globally, works across all Python environments
- Install with pip — installs into the currently active environment
To install manually:
pipx install netgreener && pipx ensurepath
Getting started
- Install the extension and open a Python project
- Click NetGreener: Log In from the Command Palette (
Ctrl+Shift+P)
- The extension auto-matches your workspace to a NetGreener project
- Press
Ctrl+Shift+G R to run and measure your script in the integrated terminal
- View results in the NetGreener sidebar
Features
Run Metrics
See energy consumption (Wh), CPU/GPU utilization, memory, and estimated CO₂ for every run — updated automatically when a run completes.
Code Issues
Scan your project for energy-inefficiency patterns with NetGreener: Scan Project for Issues ($(search) button in the sidebar). Issues are shown as:
- Inline editor diagnostics with severity indicators
- A filterable tree view in the sidebar
- CodeLens actions on flagged functions
LLM Optimization
Click Optimize Function on any flagged issue to send it to an LLM and receive a fully rewritten, energy-efficient version. Supports applying fixes one-by-one or all at once with Optimize All Issues.
Carbon Estimates
The Estimates panel projects your expected energy use and CO₂ emissions based on historical runs and detected code patterns.
Configuration
| Setting |
Default |
Description |
netgreener.cliPath |
netgreener |
Path to the CLI executable |
netgreener.apiBaseUrl |
(cloud) |
NetGreener API base URL |
netgreener.llmProvider |
(server default) |
LLM provider: azure_openai, openai, anthropic, ollama, custom |
netgreener.llmKey |
|
API key for your LLM provider |
netgreener.llmEndpoint |
|
Endpoint URL (required for Azure OpenAI, Ollama, custom) |
netgreener.llmModel |
|
Model or deployment name (e.g. gpt-4o, claude-3-5-sonnet-20241022) |
netgreener.dataPath |
|
Path or URI to training/inference data — required for full CNN/data feature extraction on AI projects (supports local paths, Azure Blob, S3, GCS) |
Bring your own LLM
NetGreener supports any LLM provider for code optimization. Set llmProvider + llmModel (and llmKey / llmEndpoint as needed) in your VS Code settings. Supported providers:
- openai — OpenAI API (GPT-4o, etc.)
- anthropic — Anthropic API (Claude 3.5, etc.)
- azure_openai — Azure OpenAI deployment
- ollama — local Ollama instance (
http://localhost:11434)
- custom — any OpenAI-compatible endpoint
Keyboard shortcuts
| Shortcut |
Action |
Ctrl+Shift+G R |
Run script in integrated terminal |
Ctrl+Shift+G L |
Open last run in dashboard |
Ctrl+Shift+G P |
Open project in dashboard |
Ctrl+Shift+G S |
Select active project |
Commands
All commands are available from the Command Palette (Ctrl+Shift+P):
NetGreener: Log In / Log Out
NetGreener: Run in Integrated Terminal
NetGreener: Scan Project for Issues
NetGreener: Optimize Function
NetGreener: Optimize All Issues
NetGreener: Open Project in Dashboard
NetGreener: Open Last Run in Dashboard
NetGreener: Select Project
NetGreener: Create Project for This Workspace
Privacy & data
Energy measurements and code analysis results are sent to the NetGreener platform associated with your account. Code sent for LLM optimization goes to your configured LLM provider (or the NetGreener server default). No data is shared with third parties.
Support