profile-dart-code

Instructions for profiling Dart command-line applications using the VM Service protocol. Helps capture CPU sampling data, identify performance bottlenecks, automate CPU analysis and generate function-call breakdown summaries, and export profiling data as JSON without requiring a browser or DevTools.

Last repository push
GitHub Stars
149
Forks
17
Issues / PRs
2

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "profile-dart-code" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-4661e5de86e4751088d0dac57dee035a5b1dc468249510a5c9aa028130aab3ec. Verify the upstream source and version against https://github.com/kevmoo/dash_skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Instructions for profiling Dart command-line applications using the VM Service protocol. Helps capture CPU sampling data, identify performance bottlenecks, automate CPU analysis and generate function-call breakdown summaries, and export profiling data as JSON without requiring a browser or DevTools.

0 Downloads

Introduction source: third_party · kevmoo · 0.0.1 Reference

SkillPi interpretation

Tasks
|-
Audience
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.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: profile-dart-code
description: |-
  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.
key_features:
  - Automated VM Service WebSocket connection
  - CPU sampling and top-function call summary
  - JSON trace export for further analysis

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_harness or package:bench_press instead).
  • Target Does Not Run Cleanly: If the target script fails to compile or crashes on startup, fix functional bugs before attempting CPU profiling.

Workflow

  1. Ensure clean compilation: Make sure the target Dart script runs cleanly (dart run <script.dart>).
  2. 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.
  3. 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). Minimum 50µs.
  • -- <target.dart> [args...]: The Dart script to profile, followed by any arguments 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.

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.json

Best Practices for Interpreting Profiles

  1. 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). High total % with low self % indicates a dispatcher or outer orchestration loop.
  2. Look for Hidden Overhead: Watch out for implicit object allocations (_copyData, iterator wrappers, closure creation) inside tight loops.
  3. Verify Optimizations Empirically: Always record baseline sample counts and execution duration (time -v) before and after applying optimizations.

Current listing version

0.0.1

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value80/100

Highlights

  • 提供针对Dart命令行应用的专用CPU性能分析能力
  • 填补了无需浏览器或DevTools场景下的性能分析空白
  • 包含明确的适用场景和避坑指南
Trigger Precision95/100

Highlights

  • 触发词覆盖全面(profile/optimize/benchmark)
  • 边界清晰,通过abstention guardrails明确定义不适用场景
  • description位置正确且内容完整
Structure and Standards95/100

Highlights

  • Phase划分清晰(编译检查->运行分析->优化建议)
  • 包含完整的端到端示例和输出展示
  • frontmatter完整,单文件结构良好
Execution Reliability85/100

Areas to improve

  • 脚本错误处理细节未明确展示 Reported severity: Minor

    文档中提到了潜在挂起风险但未详细说明脚本内部的异常处理机制

    Recommendation: 建议在文档中补充说明脚本如何处理连接失败、超时等常见异常情况

Highlights

  • 工具来源明确(官方vm_service包)
  • 参数定义清晰且有默认值
  • 对潜在风险(进程挂起)有明确警告提示
Evidence Verifiability (mean of the first four)89/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.