/benchmark
Comprehensive performance analysis and optimization orchestrator with parallel benchmarking capabilities
How it fires
How this command gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/benchmark
Context preview
What this command does when you run it.
Comprehensive performance analysis and optimization orchestrator with parallel benchmarking capabilities
Command definition
benchmark.mdallowed-tools: Task, Bash(hyperfine:*), Bash(rg:*), Bash(fd:*), Bash(wrk:*), Bash(k6:*), Bash(perf:*), Bash(jq:*), Bash(gdate:*), Bash(cargo:*), Bash(go:*), Bash(mvn:*), Bash(deno:*), Bash(valgrind:*), Bash(time:*), Bash(docker:*), Bash(curl:*), Bash(psql:*), Bash(dragonfly-cli:*), Bash(stress:*), Read, Write
name: "Benchmark"
description: "Comprehensive performance analysis and optimization orchestrator with parallel benchmarking capabilities"
author: "wcygan"
tags: ["ops","perf"]
version: "1.0.0"
created_at: "2025-07-14T00:00:00Z"
updated_at: "2025-07-14T00:00:00Z"
Context
- Session ID: !`gdate +%s%N 2>/dev/null || date +%s%N 2>/dev/null || echo "$(date +%s)$(jot -r 1 100000 999999 2>/dev/null || shuf -i 100000-999999 -n 1 2>/dev/null || echo $RANDOM$RANDOM)"`
- Benchmark target: $ARGUMENTS
- Project type: !`fd "(Cargo.toml|go.mod|package.json|pom.xml|deno.json)" . -d 2 | head -3 || echo "No build files detected"`
- Available performance tools: !`echo "hyperfine: $(which hyperfine >/dev/null && echo ✓ || echo ❌) | wrk: $(which wrk >/dev/null && echo ✓ || echo ❌) | k6: $(which k6 >/dev/null && echo ✓ || echo ❌) | perf: $(which perf >/dev/null && echo ✓ || echo ❌)"`
- Current directory: !`pwd`
- System specs: !`echo "CPU: $(sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 'unknown') cores | RAM: $(echo $(($(sysctl -n hw.memsize 2>/dev/null || grep MemTotal /proc/meminfo 2>/dev/null | awk '{print $2}' || echo 0) / 1024 / 1024))MB 2>/dev/null || echo 'unknown')MB"`
- Git status: !`git status --porcelain | wc -l | tr -d ' '` uncommitted changes
Your Task
STEP 1: Initialize comprehensive performance analysis session
- CREATE session state file: `/tmp/benchmark-session-$SESSION_ID.json`
- ANALYZE project structure and detect benchmark targets
- VALIDATE performance tooling availability (hyperfine, wrk, perf are MANDATORY)
- DETERMINE benchmarking strategy based on project type and target
# Initialize benchmark session state
echo '{
"sessionId": "'$SESSION_ID'",
"target": "'$ARGUMENTS'",
"projectType": "auto-detect",
"benchmarkStrategy": "comprehensive",
"phases": ["baseline", "profiling", "optimization", "validation"],
"currentPhase": "baseline",
"results": {},
"recommendations": []
}' > /tmp/benchmark-session-$SESSION_ID.jsonSTEP 2: Adaptive benchmarking strategy with parallel execution
TRY:
CASE project_complexity: WHEN "simple_binary":
- EXECUTE direct hyperfine benchmarking with system monitoring
- PROFILE with built-in tools
- GENERATE immediate optimization recommendations
WHEN "multi_component_system":
- LAUNCH parallel sub-agents for comprehensive analysis
- COORDINATE results from multiple benchmark domains
- SYNTHESIZE findings into holistic performance profile
WHEN "distributed_application":
- ORCHESTRATE load testing scenarios
- MONITOR system-wide performance metrics
- ANALYZE bottlenecks across service boundaries
**Parallel Performance Analysis (Sub-Agent Architecture):**
IF project_complexity == "complex" OR benchmark_scope == "comprehensive":
LAUNCH parallel sub-agents for multi-dimensional performance analysis:
- **Agent 1: Binary Performance**: Baseline measurement with hyperfine and system profiling
- Focus: Execution time, memory usage, CPU utilization patterns
- Tools: hyperfine, time, valgrind, perf for CPU/memory profiling
- Output: Baseline metrics and hotspot identification
- **Agent 2: API/Service Performance**: HTTP endpoint and service layer benchmarking
- Focus: Throughput, latency percentiles, connection handling
- Tools: wrk, k6 for load testing, curl for endpoint validation
- Output: Service performance characteristics and scaling limits
- **Agent 3: Database Performance**: Data layer optimization and query analysis
- Focus: Connection pooling, query performance, transaction throughput
- Tools: Database-specific profiling, connection pool testing
- Output: Database bottlenecks and optimization opportunities
- **Agent 4: System Resource Analysis**: Infrastructure and resource utilization
- Focus: Memory patterns, CPU hotspots, I/O characteristics
- Tools: perf, system monitoring, resource profiling
- Output: System-level optimization recommendations
- **Agent 5: Regression Testing**: Historical performance comparison and CI integration
- Focus: Performance trend analysis, regression detection, automated testing setup
- Tools: Benchmark result comparison, JSON analysis, CI pipeline integration
- Output: Performance monitoring and alerting configuration
**Sub-Agent Coordination:**
# Each agent reports findings to session state
echo "Parallel performance analysis agents launched..."
echo "Results will be aggregated for comprehensive optimization strategy"
STEP 3: Baseline performance measurement with intelligent detection
**Language-Specific Benchmarking:**
# Rust Performance Analysis
if fd "Cargo.toml" . | head -1 >/dev/null; then
echo "🦀 Rust project detected - comprehensive Rust benchmarking"
# Built-in benchmarks with detailed metrics
cargo bench --bench '*' -- --output-format json > /tmp/rust-bench-$SESSION_ID.json
# Release build optimization verification
cargo build --release --verbose
# Hyperfine analysis with statistical rigor
hyperfine --warmup 5 --runs 20 \
--export-json /tmp/rust-hyperfine-$SESSION_ID.json \
--parameter-scan threads 1 $(nproc) \
'RAYON_NUM_THREADS={threads} ./target/release/$(basename $PWD)' || \
hyperfine --warmup 5 --runs 20 './target/release/$(basename $PWD)'
# Memory profiling with Rust-specific tools
if command -v heaptrack >/dev/null; then
heaptrack ./target/release/$(basename $PWD) > /tmp/rust-memory-$SESSION_ID.log
fi
fi
# Go Performance Analysis
if fd "go.mod" . | head -1 >/dev/null; then
echo "🐹 Go project detected - comprehensive Go benchmarking"
# Built-in benchmarks with memory allocation tracking
go test -bench=. -benchmem -cpuprofiRead more
allowed-tools: Task, Bash(hyperfine:*), Bash(rg:*), Bash(fd:*), Bash(wrk:*), Bash(k6:*), Bash(perf:*), Bash(jq:*), Bash(gdate:*), Bash(cargo:*), Bash(go:*), Bash(mvn:*), Bash(deno:*), Bash(valgrind:*), Bash(time:*), Bash(docker:*), Bash(curl:*), Bash(psql:*), Bash(dragonfly-cli:*), Bash(stress:*), Read, Write name: "Benchmark" description: "Comprehensive performance analysis and optimization orchestrator with parallel benchmarking capabilities" author: "wcygan" tags: ["ops","perf"] version: "1.0.0" created_at: "2025-07-14T00:00:00Z" updated_at: "2025-07-14T00:00:00Z"
Context
- Session ID: !`gdate +%s%N 2>/dev/null || date +%s%N 2>/dev/null || echo "$(date +%s)$(jot -r 1 100000 999999 2>/dev/null || shuf -i 100000-999999 -n 1 2>/dev/null || echo $RANDOM$RANDOM)"`
- Benchmark target: $ARGUMENTS
- Project type: !`fd "(Cargo.toml|go.mod|package.json|pom.xml|deno.json)" . -d 2 | head -3 || echo "No build files detected"`
- Available performance tools: !`echo "hyperfine: $(which hyperfine >/dev/null && echo ✓ || echo ❌) | wrk: $(which wrk >/dev/null && echo ✓ || echo ❌) | k6: $(which k6 >/dev/null && echo ✓ || echo ❌) | perf: $(which perf >/dev/null && echo ✓ || echo ❌)"`
- Current directory: !`pwd`
- System specs: !`echo "CPU: $(sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 'unknown') cores | RAM: $(echo $(($(sysctl -n hw.memsize 2>/dev/null || grep MemTotal /proc/meminfo 2>/dev/null | awk '{print $2}' || echo 0) / 1024 / 1024))MB 2>/dev/null || echo 'unknown')MB"`
- Git status: !`git status --porcelain | wc -l | tr -d ' '` uncommitted changes
Your Task
STEP 1: Initialize comprehensive performance analysis session
- CREATE session state file: `/tmp/benchmark-session-$SESSION_ID.json`
- ANALYZE project structure and detect benchmark targets
- VALIDATE performance tooling availability (hyperfine, wrk, perf are MANDATORY)
- DETERMINE benchmarking strategy based on project type and target
# Initialize benchmark session state
echo '{
"sessionId": "'$SESSION_ID'",
"target": "'$ARGUMENTS'",
"projectType": "auto-detect",
"benchmarkStrategy": "comprehensive",
"phases": ["baseline", "profiling", "optimization", "validation"],
"currentPhase": "baseline",
"results": {},
"recommendations": []
}' > /tmp/benchmark-session-$SESSION_ID.jsonSTEP 2: Adaptive benchmarking strategy with parallel execution
TRY:
CASE project_complexity: WHEN "simple_binary":
- EXECUTE direct hyperfine benchmarking with system monitoring
- PROFILE with built-in tools
- GENERATE immediate optimization recommendations
WHEN "multi_component_system":
- LAUNCH parallel sub-agents for comprehensive analysis
- COORDINATE results from multiple benchmark domains
- SYNTHESIZE findings into holistic performance profile
WHEN "distributed_application":
- ORCHESTRATE load testing scenarios
- MONITOR system-wide performance metrics
- ANALYZE bottlenecks across service boundaries
**Parallel Performance Analysis (Sub-Agent Architecture):**
IF project_complexity == "complex" OR benchmark_scope == "comprehensive":
LAUNCH parallel sub-agents for multi-dimensional performance analysis:
- **Agent 1: Binary Performance**: Baseline measurement with hyperfine and system profiling
- Focus: Execution time, memory usage, CPU utilization patterns
- Tools: hyperfine, time, valgrind, perf for CPU/memory profiling
- Output: Baseline metrics and hotspot identification
- **Agent 2: API/Service Performance**: HTTP endpoint and service layer benchmarking
- Focus: Throughput, latency percentiles, connection handling
- Tools: wrk, k6 for load testing, curl for endpoint validation
- Output: Service performance characteristics and scaling limits
- **Agent 3: Database Performance**: Data layer optimization and query analysis
- Focus: Connection pooling, query performance, transaction throughput
- Tools: Database-specific profiling, connection pool testing
- Output: Database bottlenecks and optimization opportunities
- **Agent 4: System Resource Analysis**: Infrastructure and resource utilization
- Focus: Memory patterns, CPU hotspots, I/O characteristics
- Tools: perf, system monitoring, resource profiling
- Output: System-level optimization recommendations
- **Agent 5: Regression Testing**: Historical performance comparison and CI integration
- Focus: Performance trend analysis, regression detection, automated testing setup
- Tools: Benchmark result comparison, JSON analysis, CI pipeline integration
- Output: Performance monitoring and alerting configuration
**Sub-Agent Coordination:**
# Each agent reports findings to session state echo "Parallel performance analysis agents launched..." echo "Results will be aggregated for comprehensive optimization strategy"
STEP 3: Baseline performance measurement with intelligent detection
**Language-Specific Benchmarking:**
# Rust Performance Analysis
if fd "Cargo.toml" . | head -1 >/dev/null; then
echo "🦀 Rust project detected - comprehensive Rust benchmarking"
# Built-in benchmarks with detailed metrics
cargo bench --bench '*' -- --output-format json > /tmp/rust-bench-$SESSION_ID.json
# Release build optimization verification
cargo build --release --verbose
# Hyperfine analysis with statistical rigor
hyperfine --warmup 5 --runs 20 \
--export-json /tmp/rust-hyperfine-$SESSION_ID.json \
--parameter-scan threads 1 $(nproc) \
'RAYON_NUM_THREADS={threads} ./target/release/$(basename $PWD)' || \
hyperfine --warmup 5 --runs 20 './target/release/$(basename $PWD)'
# Memory profiling with Rust-specific tools
if command -v heaptrack >/dev/null; then
heaptrack ./target/release/$(basename $PWD) > /tmp/rust-memory-$SESSION_ID.log
fi
fi
# Go Performance Analysis
if fd "go.mod" . | head -1 >/dev/null; then
echo "🐹 Go project detected - comprehensive Go benchmarking"
# Built-in benchmarks with memory allocation tracking
go test -bench=. -benchmem -cpuprofiA lightweight (~46kB) and comprehensive CLI tool for managing Claude commands, configurations, and workflows.
Repo: kiliczsh/claude-cmd
Other commands on claude-cmd.
- /agent-browser-automation
Automate browser interactions for development testing using Puppeteer MCP
Open command - /agent-prep-merge
Prepare branches for merging across multiple worktrees and coordinate integration
Open command - /agent-persona-accessibility-expert
Transform into accessibility expert for WCAG compliance and inclusive design
Open command - /agent-persona-api-designer
Transform into an API design specialist who creates well-structured, developer-friendly APIs
Open command - /agent-persona-backend-specialist
Transform into backend specialist for scalable API and system design
Open command - /agent-persona-cloud-architect
Cloud architect persona for designing scalable, secure cloud infrastructure using modern cloud-native technologies
Open command

