{"id":36973344,"url":"https://github.com/waydotnet/profiler-powered-by-scalene","last_synced_at":"2026-01-13T22:00:49.925Z","repository":{"id":331021581,"uuid":"1124885293","full_name":"WaYdotNET/profiler-powered-by-scalene","owner":"WaYdotNET","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-29T22:42:48.000Z","size":858,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-13T20:41:49.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WaYdotNET.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-29T19:35:26.000Z","updated_at":"2025-12-29T22:42:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/WaYdotNET/profiler-powered-by-scalene","commit_stats":null,"previous_names":["waydotnet/profiler-powered-by-scalene"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/WaYdotNET/profiler-powered-by-scalene","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WaYdotNET%2Fprofiler-powered-by-scalene","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WaYdotNET%2Fprofiler-powered-by-scalene/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WaYdotNET%2Fprofiler-powered-by-scalene/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WaYdotNET%2Fprofiler-powered-by-scalene/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WaYdotNET","download_url":"https://codeload.github.com/WaYdotNET/profiler-powered-by-scalene/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WaYdotNET%2Fprofiler-powered-by-scalene/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28403750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-13T22:00:24.337Z","updated_at":"2026-01-13T22:00:49.907Z","avatar_url":"https://github.com/WaYdotNET.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Profiler Powered by Scalene\n\n[![Open VSX](https://img.shields.io/badge/Open%20VSX-ready-brightgreen)](https://open-vsx.org/)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue)](https://www.typescriptlang.org/)\n[![Rosé Pine](https://img.shields.io/badge/Theme-Ros%C3%A9%20Pine%20Dawn-ea9d34?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCIgZmlsbD0iI2ZhZjRlZCIvPgogIDxjaXJjbGUgY3g9IjEyIiBjeT0iMTIiIHI9IjYiIGZpbGw9IiNlYTlkMzQiLz4KPC9zdmc+)](https://rosepinetheme.com/)\n[![GitHub](https://img.shields.io/badge/GitHub-WaYdotNET-blue?logo=github)](https://github.com/WaYdotNET)\n\nA powerful VS Code extension for [Scalene](https://github.com/plasma-umass/scalene) - the AI-powered CPU, GPU, and memory profiler for Python.\n\n**Built for Open VSX** - Works in Cursor, VSCodium, and other VS Code alternatives.\n\n**Author:** [Carlo Bertini (WaYdotNET)](https://github.com/WaYdotNET)\n\n---\n\n## 🎯 Inspired By\n\nThis extension is **inspired by** the official [Scalene VS Code Extension](https://github.com/plasma-umass/scalene-vscode-extension) by [Emery Berger](https://github.com/emeryberger).\n\nThe original extension is available on the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=EmeryBerger.scalene) but **not on Open VSX**, which is required for Cursor, VSCodium, and other open-source VS Code alternatives.\n\n---\n\n## ✨ What's Different from the Original\n\n| Feature | Original Extension | This Extension |\n|---------|-------------------|----------------|\n| **Open VSX Support** | ❌ Not available | ✅ Available |\n| **Built-in Profile Viewer** | ❌ Opens in browser only | ✅ Integrated webview with [Rosé Pine Dawn](https://rosepinetheme.com/) theme |\n| **Source Code Display** | ❌ Not shown | ✅ **Shows source code for each line** |\n| **Complete Metrics** | ⚠️ Basic | ✅ **All Scalene metrics (CPU, Memory, Peak, Copy, Growth)** |\n| **Function Profiles** | ❌ Not available | ✅ **Dedicated function profile view** |\n| **Memory Leak Detection UI** | ❌ CLI output only | ✅ Dedicated \"Potential Leaks\" tab **with code** |\n| **Memory-Only Mode** | ❌ Not available | ✅ Focus profiling on memory |\n| **Profile Selected Code** | ❌ Not available | ✅ Profile just selected region |\n| **Auto-detect Python** | ⚠️ Basic | ✅ Integrates with VS Code Python extension |\n| **uv Support** | ❌ | ✅ **Auto-detects uv + pyproject.toml** |\n| **Status Bar Integration** | ❌ Not available | ✅ Quick access from status bar |\n| **Namespace** | `scalene.*` | `profilerScalene.*` (no conflicts!) |\n| **Codebase** | JavaScript | TypeScript with strict mode |\n\n---\n\n## Features\n\n| Feature | Description |\n|---------|-------------|\n| 🔥 **CPU Profiling** | Line-level CPU usage with Python vs native code breakdown |\n| 💾 **Memory Profiling** | Track memory allocations, peak usage, and copy operations per line |\n| 🚨 **Memory Leak Detection** | Automatically identifies potential memory leaks **with source code** |\n| 📊 **Built-in Profile Viewer** | Beautiful [Rosé Pine Dawn](https://rosepinetheme.com/) themed webview showing **source code + all metrics** |\n| ⚡ **Function Profiles** | See which functions consume the most resources |\n| 📝 **Source Code Display** | See the actual code for each profiled line |\n| 🌐 **Scalene Web Viewer** | Open profiles in Scalene's native web UI |\n| ⚡ **Low Overhead** | Sampling-based profiling with minimal slowdown |\n| 🔧 **Auto-Install** | Automatically installs Scalene with uv or pip |\n\n## Requirements\n\n- Python 3.8+\n- Scalene (auto-installed if missing)\n- Optional: uv (for faster installation if pyproject.toml exists)\n\n## Quick Start\n\n1. Open a Python file\n2. Click the **🔥 Profiler** button in the status bar, or\n3. Right-click → **Profiler: Profile Current File**\n4. View results in the integrated viewer with **source code + metrics**\n\n## Commands\n\n| Command | Description |\n|---------|-------------|\n| `Profiler: Profile Current File` | Profile the entire file |\n| `Profiler: Profile Memory Only` | Focus on memory profiling |\n| `Profiler: Profile Selected Code` | Profile selected code region |\n| `Profiler: View Last Profile` | Open built-in profile viewer |\n| `Profiler: Open in Scalene Web Viewer` | Open in browser |\n| `Profiler: Stop Profiling` | Stop current session |\n| `Profiler: Install Scalene` | Install/update Scalene (auto-detects uv) |\n\n## Profile Viewer\n\nThe built-in profile viewer uses the **[Rosé Pine Dawn](https://rosepinetheme.com/)** theme (WCAG AAA compliant) and has four tabs:\n\n### 📊 Line Profile\n\nShows for each line:\n- **Line Number**\n- **📝 Source Code** (the actual code!)\n- **CPU (Python)** - Time in Python code\n- **CPU (Native)** - Time in C/C++ libraries\n- **Memory (Avg MB)** - Average memory allocated\n- **Memory (Peak MB)** - Peak memory usage\n- **Copy (MB/s)** - Memory copy rate (high = inefficient)\n- **Growth (MB)** - Memory growth (leak indicator)\n\n### ⚡ Functions\n\n- Function name and location\n- CPU time breakdown\n- Memory usage\n- Peak memory\n\n### 🚨 Potential Leaks\n\n- **📝 Source code** of leaking lines\n- Leak score (0-100%)\n- Memory allocated\n- File:Line location\n\n### 📖 About\n\n- Complete metrics guide and quick tips\n- Color coding reference\n- Links to Scalene, extension repository, and theme\n\n## Extension Settings\n\n| Setting | Description | Default |\n|---------|-------------|---------|\n| `profilerScalene.pythonPath` | Python interpreter path | Auto-detect |\n| `profilerScalene.cpuSamplingRate` | CPU sampling rate (seconds) | `0.01` |\n| `profilerScalene.reducedProfile` | Only show significant lines | `true` |\n| `profilerScalene.outputDirectory` | Profile output directory | `.scalene-profiles` |\n| `profilerScalene.autoOpenViewer` | Auto-open viewer after profiling | `true` |\n| `profilerScalene.showMemoryLeaks` | Show potential leaks tab | `true` |\n\n\n## Development\n\n```bash\nnpm install       # Install dependencies\nnpm run compile   # Build\nnpm run watch     # Watch mode\nnpm run package   # Create .vsix\n```\n\n**Requirements:** Node.js 18+, npm\n\n## Installation\n\n### From Open VSX (Cursor/VSCodium)\n\nSearch for \"Profiler Powered by Scalene\" in the Extensions view, or:\n\n```\next install WaYdotNET.profiler-powered-by-scalene\n```\n\n### From VSIX\n\n1. Download the `.vsix` file from [Releases](https://github.com/WaYdotNET/profiler-powered-by-scalene/releases)\n2. In VS Code/Cursor: `Ctrl+Shift+P` → \"Install from VSIX\"\n3. Select the `.vsix` file\n\n## 🐍 Profiling Django Applications\n\n### Method 1: Test Client Script (⭐ Recommended)\n\n```python\n# profile_api.py\nimport os, django\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')\ndjango.setup()\n\nfrom django.test import Client\nclient = Client()\n\nfor i in range(100):\n    response = client.get('/api/users/')\n    print(f\"✓ {i}: {response.status_code}\")\n```\n\nRun: **Profiler: Profile Current File** on `profile_api.py`\n\n### Method 2: Profile runserver\n\n```bash\nscalene run -o profile.json manage.py --- runserver 0:8000 --noreload\n# Make requests, then Ctrl+C\n# In Cursor: Profiler: View Last Profile\n```\n\n⚠️ Always use `--noreload` to prevent auto-reloader issues\n\n---\n\n### Method 3: Profile Specific View\n\n```python\n# profile_view.py\nimport os, django\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')\ndjango.setup()\n\nfrom myapp.views import expensive_view\nfrom django.test import RequestFactory\n\nfor i in range(50):\n    request = RequestFactory().get('/my-url/')\n    response = expensive_view(request)\n```\n\n### Method 4: Profile Management Command\n\n```python\n# profile_command.py\nimport os\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')\nfrom django.core.management import execute_from_command_line\n\nexecute_from_command_line(['manage.py', 'your_command', '--args'])\n```\n\n---\n\n### Method 5: Profile ORM Queries\n\n```python\n# profile_queries.py\nimport os, django\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')\ndjango.setup()\n\nfrom myapp.models import User\n\nusers = User.objects.all()[:100]\nfor user in users:\n    orders = user.orders.all()  # N+1 query?\n    print(f\"User {user.id}: {len(orders)} orders\")\n```\n\n**Look for:** High CPU (Native) = DB calls, High Memory (Peak) = Large querysets\n\n---\n\n### 🔍 What to Look For\n\n| Issue | Indicator | Solution |\n|-------|-----------|----------|\n| **Memory Leak** | Growth \u003e 0, Growth Rate \u003e 110% | Check cached querysets, signal handlers, sessions |\n| **Slow Views** | High CPU (Python) | Optimize serializers, templates, business logic |\n| **Database** | High CPU (Native) | Use `select_related()`, `prefetch_related()`, check N+1 queries |\n| **Memory Usage** | High Peak MB | Use `.iterator()`, pagination, streaming |\n\n### 💡 Best Practices\n\n- ✅ Use `--noreload` with runserver profiling\n- ✅ Profile 50-100 iterations for reliable data\n- ✅ Use **Profiler: Profile Memory Only** for leak detection\n- ✅ Profile realistic workloads (not empty DBs)\n\n## Credits\n\n- **[Scalene](https://github.com/plasma-umass/scalene)** - The underlying profiler by Emery Berger, Sam Stern, and Juan Altmayer Pizzorno\n- **[Original VS Code Extension](https://github.com/plasma-umass/scalene-vscode-extension)** - Inspiration for this extension by Emery Berger\n- **[Carlo Bertini (WaYdotNET)](https://github.com/WaYdotNET)** - Author of this enhanced Open VSX version\n\n## License\n\nApache License 2.0 - see [LICENSE](LICENSE)\n\n---\n\n**Made with ❤️ by [WaYdotNET](https://github.com/WaYdotNET)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaydotnet%2Fprofiler-powered-by-scalene","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaydotnet%2Fprofiler-powered-by-scalene","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaydotnet%2Fprofiler-powered-by-scalene/lists"}