profile-dart-code
Skill148 starsChanged 13 days agoApache-2.0View on GitHub
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.
In this repository11 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
When asked to profile, optimize, or benchmark CPU execution of a Dart script or CLI tool.
- Distinctive: line 23
When investigating hot loops, heavy function calls, or unexpected execution overhead.
- Distinctive: line 28
Do NOT profile using this skill when:
- Distinctive: line 38
Target Does Not Run Cleanly: If the target script fails to compile or crashes on startup, fix functional bugs before attempting CPU …
- Very specific: line 43
Ensure clean compilation: Make sure the target Dart script runs cleanly (dart run <script.dart>).
- Distinctive: line 45
Run Profiler Script: Use the automated profiling helper script inside this skill directory to launch the target app with VM Service …
- Distinctive: line 59
Run it from any working directory:
- Very specific: line 101
Verify Optimizations Empirically: Always record baseline sample counts and execution duration (time -v) before and after applying …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Dart CPU Profiling
Guidelines and automated tools for capturing CPU profiles and identifying bottlenecks in Dart command-line applications.
When to use this skill
- When asked to profile, optimize, or benchmark CPU execution of a Dart script or CLI tool.
- When investigating hot loops, heavy function calls, or unexpected execution overhead.
When NOT to use (Abstention Guardrails)
Do NOT profile using this skill when:
- Pure I/O-Bound Bottlenecks: The performance bottleneck is network latency, database queries, or disk I/O wait rather than CPU execution.
- Flutter UI Applications: The target is a Flutter application requiring
frame profiling, raster thread inspection, or widget rebuild tracking (use
Flutter DevTools or
widget_inspector). - Short-Lived Micro-Benchmarks: Micro-benchmarks running for only a few
milliseconds where VM warmup and sampling overhead skew results (use
package:benchmark_harnessorpackage:bench_pressinstead). - Target Does Not Run Cleanly: If the target script fails to compile or crashes on startup, fix functional bugs before attempting CPU profiling.
Workflow
- Ensure clean compilation: Make sure the target Dart script runs cleanly
(
dart run <script.dart>). - Run Profiler Script: Use the automated profiling helper script inside this skill directory to launch the target app with VM Service observability enabled, capture CPU samples, and output top-consuming functions.
- Analyze & Optimize: Review the self and total sample percentages reported by the tool to pinpoint bottlenecks (e.g., excessive object allocation, costly hashing, virtual dispatch overhead).
Running the Profiler Helper Script
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...]Script 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). Minimum50µs.-- <target.dart> [args...]: The Dart script to profile, followed by any arguments passed tomain().
[!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.
Example 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.jsonBest Practices for Interpreting Profiles
- Focus on Self % vs. Total %: High
self %indicates where CPU time is spent directly inside a function's own body (math, loop branching, array indexing). Hightotal %with lowself %indicates a dispatcher or outer orchestration loop. - Look for Hidden Overhead: Watch out for implicit object allocations
(
_copyData, iterator wrappers, closure creation) inside tight loops. - Verify Optimizations Empirically: Always record baseline sample counts
and execution duration (
time -v) before and after applying optimizations.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

