AGENT SKILL

perf-profile

Performance profiling — measures code execution time, DB call time, and identifies bottlenecks at both the application and database layer. Use when asked to "profile performance", "measure execution time", "find bottlenecks", "check response times", or "why is this slow".

License 许可
MIT
最近更新
2026-11-01
Stars
★ 12
Forks
0

01 前言 Front Matter

name
perf-profile
version
1.0.0
triggers
[ "profile performance", "measure execution time", "find bottlenecks", "why is this slow", "check response times", "performance profiling" ]
description
Performance profiling — measures code execution time, DB call time, and identifies bottlenecks at both the application and database layer. Use when asked to "profile performance", "measure execution time", "find bottlenecks", "check response times", or "why is this slow".
allowed-tools
[ "Bash", "Read", "Grep", "Glob" ]

03 SKILL.md 正文

/perf-profile

Profile application performance: code execution time, DB call time, and bottleneck identification at both the application and database layer.

Step 1: Identify the target

Ask the user (or infer from context): what are we profiling?

  • A specific endpoint / route
  • A background job / worker
  • A specific function or module
  • The whole application (general audit)

Step 2: DB call time profiling

PostgreSQL

# Enable timing in psql
psql "$DATABASE_URL" -c "\timing on"

# Check pg_stat_statements for query timing (if available)
psql "$DATABASE_URL" -c "
  SELECT
    LEFT(query, 80) AS query,
    calls,
    ROUND(mean_exec_time::numeric, 2) AS mean_ms,
    ROUND(total_exec_time::numeric, 2) AS total_ms,
    ROUND((total_exec_time / SUM(total_exec_time) OVER ()) * 100, 1) AS pct_total
  FROM pg_stat_statements
  ORDER BY mean_exec_time DESC
  LIMIT 20;
" 2>/dev/null || echo "pg_stat_statements not available — enable with: CREATE EXTENSION pg_stat_statements;"

MySQL / MariaDB

mysql -e "
  SELECT
    LEFT(DIGEST_TEXT, 80) AS query,
    COUNT_STAR AS calls,
    ROUND(AVG_TIMER_WAIT/1e9, 2) AS mean_ms,
    ROUND(SUM_TIMER_WAIT/1e9, 2) AS total_ms
  FROM performance_schema.events_statements_summary_by_digest
  ORDER BY AVG_TIMER_WAIT DESC
  LIMIT 20;
" 2>/dev/null || echo "MySQL performance_schema unavailable"

Report: table of top 20 queries by mean execution time, with call count and % of total DB time.

Step 3: Application-level profiling

Detect the runtime and suggest the right profiler:

# Detect language/framework
[ -f package.json ] && echo "RUNTIME=node"
[ -f Gemfile ] && echo "RUNTIME=ruby"
[ -f requirements.txt ] || [ -f pyproject.toml ] && echo "RUNTIME=python"
[ -f go.mod ] && echo "RUNTIME=go"
[ -f pom.xml ] || [ -f build.gradle ] && echo "RUNTIME=java"

Node.js:

  • Built-in: node --prof app.js + node --prof-process isolate-*.log
  • For web: add --inspect and use Chrome DevTools profiler
  • Suggest: clinic.js (npx clinic doctor -- node app.js) for flame graphs

Ruby:

  • Suggest: stackprof or rack-mini-profiler for Rails
  • For a specific method: wrap with Benchmark.measure { ... }

Python:

  • Built-in: python -m cProfile -s cumulative script.py
  • For web: py-spy top --pid <pid> for live profiling
  • Suggest: snakeviz for visualization

Go:

  • Built-in: go tool pprof http://localhost:6060/debug/pprof/profile
  • Add import _ "net/http/pprof" to enable the endpoint

Scan for existing timing instrumentation:

grep -rn "benchmark\|timing\|elapsed\|duration\|stopwatch\|time\.now\|Time\.now\|perf_hook\|performance\.now" \
  --include="*.rb" --include="*.py" --include="*.js" --include="*.ts" --include="*.go" \
  . 2>/dev/null | head -20

Step 4: Code-level bottleneck scan

Scan for common performance anti-patterns in the codebase:

Synchronous blocking in async contexts:

grep -rn "fs\.readFileSync\|execSync\|spawnSync\|sleep\|time\.Sleep" \
  --include="*.js" --include="*.ts" --include="*.go" . 2>/dev/null | head -10

Missing pagination (unbounded queries):

grep -rn "\.all\b\|find_all\|SELECT \*\b" \
  --include="*.rb" --include="*.py" --include="*.js" --include="*.ts" . 2>/dev/null | head -10

Repeated expensive calls in loops:

grep -rn "each\|forEach\|for " \
  --include="*.rb" --include="*.py" --include="*.js" --include="*.ts" . 2>/dev/null | head -20

For each flagged file, read the context and assess impact.

Step 5: Response time targets

Evaluate findings against these thresholds:

Metric Good Acceptable Needs Fix
DB query mean time <10ms <100ms >100ms
DB calls per request ≤3 ≤10 >10
Endpoint response time <100ms <500ms >500ms
Background job duration <1s <30s >30s

Step 6: Bottleneck report

## Performance Profile Report

### DB Layer
- Slowest query: <query> — Xms mean (Y calls/min)
- Total DB time as % of request: Z%
- Queries over 100ms: N

### Application Layer
- Blocking calls found: X
- Unbounded queries (no LIMIT): Y
- Loops with expensive operations: Z

### Top 3 Bottlenecks (by estimated impact)
1. <bottleneck> — estimated Xms saved per request
2. <bottleneck> — estimated Yms saved per request
3. <bottleneck> — estimated Zms saved per request

### Recommended profiling tools for this stack
- <tool 1>
- <tool 2>

Ask: "Want me to implement fixes for the top bottlenecks, or set up profiling instrumentation so you can measure before/after?"

04 同仓库更多 Skills

ariadoss
ariadoss/superskills

youtube

Download YouTube video transcripts when user provides a YouTube URL or asks to download/get/fetch a transcript from YouTube. Also use when user wants to transcribe or get captions/subtitles from a YouTube video.

图像与多媒体
★ 12
ariadoss
ariadoss/superskills

write-plan

Use when you have a spec or requirements for a multi-step task, before touching code. Produces an engineering plan complete with TDD tasks, DRY/SOLID/YAGNI principles, a required Test Plan & Verification section, and a coverage target — then auto-runs /plan-eng-review as an independent double-check before execution.

★ 12
ariadoss
ariadoss/superskills

worktrees

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification

★ 12
ariadoss
ariadoss/superskills

web-perf

Analyzes web performance using Chrome DevTools MCP. Measures Core Web Vitals (LCP, INP, CLS) and supplementary metrics (FCP, TBT, Speed Index), identifies render-blocking resources, network dependency chains, layout shifts, caching issues, and accessibility gaps. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed. Biases towards retrieval from current documentation over pre-trained knowledge.

Skill与智能体开发
★ 12
ariadoss
ariadoss/superskills

verify

Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

★ 12
ariadoss
ariadoss/superskills

validate-idea

Validate a business idea using the minimalist entrepreneur framework. Use when someone has a business idea and wants to test if it's worth pursuing before building anything.

★ 12