kevmoo/profile-dart-code
|- Profile Dart command-line applications using the VM Service protocol to capture CPU samples and identify performance bottlenecks. Helps agents automate CPU profiling, generate function call breakdown summaries, and export JSON profiles without a browser or DevTools.
npx skills add https://github.com/kevmoo/dash_skills --skill profile-dart-code
Guidelines and automated tools for capturing CPU profiles and identifying
bottlenecks in Dart command-line applications.
or CLI tool.
overhead.
(dart run <script.dart>).
this skill directory to launch the target app with VM Service observability
enabled, capture CPU samples, and output top-consuming functions.
reported by the tool to pinpoint bottlenecks (e.g., excessive object
allocation, costly hashing, virtual dispatch overhead).
This repository includes a zero-dependency (using only official vm_service)
profiling script that launches any Dart file, connects to the VM Service, waits
for execution to complete (--pause-isolates-on-exit), retrieves CPU samples,
and prints a clean summary while exporting the full JSON profile.
Run it from any working directory:
dart run <dash_skills_repo>/skills/profile-dart-code/scripts/bin/profile.dart --out=cpu_profile.json -- <path_to_target.dart> [target_arguments...]
-o, --out=<file>: Output file path to save the raw JSON CPU profile(default: cpu_profile.json).
-p, --period=<micros>: Sampling interval in microseconds (default: 1000µs= 1ms). Minimum 50µs.
-- <target.dart> [args...]: The Dart script to profile, followed by anyarguments passed to main().
> [!WARNING]
> Potential Hangs: When profiling or debugging Dart targets using VM services,
> target exceptions or connection issues can cause the process to hang
> indefinitely. Ensure your target script handles timeouts, and monitor the
> process output.
Connecting to VM service at ws://127.0.0.1:8181/ws...
Target execution paused at exit. Retrieving CPU profile samples...
=== Top CPU Functions (Self Samples) ===
1. _PuzzleSmart._shiftSlice (self: 34.2%, total: 41.0%)
2. _countInversions (self: 18.5%, total: 18.5%)
3. shortestPaths (self: 12.1%, total: 98.4%)
Saved complete JSON profile to: cpu_profile.json
self % indicates where CPU time isspent directly inside a function's own body (math, loop branching, array
indexing). High total % with low self % indicates a dispatcher or outer
orchestration loop.
(_copyData, iterator wrappers, closure creation) inside tight loops.
and execution duration (time -v) before and after applying optimizations.
Take kevmoo/profile-dart-code from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.