v2/benchmark/docs/basic-usage.md
Learn how to use the swarm benchmarking tool effectively with practical examples and common workflows.
Before diving into usage, understand these key concepts:
The simplest way to start:
swarm-benchmark run "Create a hello world API"
This command:
auto strategy (automatically selects approach)centralized coordination (single coordinator)./reports/After running a benchmark:
# List all benchmarks
swarm-benchmark list
# Output:
# ID | Name | Status | Duration
# ------------------------------------ | ----------------------- | --------- | --------
# 7263107f-9031-4403-901c-9db6e3fc96c6 | benchmark-auto-central | completed | 0.20s
View specific benchmark details:
swarm-benchmark show 7263107f-9031-4403-901c-9db6e3fc96c6
When you need to gather information:
# Research a topic with distributed agents
swarm-benchmark run "Research best practices for REST API design" \
--strategy research \
--mode distributed \
--max-agents 6
# View the research results
swarm-benchmark show <benchmark-id> --format detailed
For code creation tasks:
# Step 1: Research the requirements
swarm-benchmark run "Research authentication methods" --strategy research
# Step 2: Develop the solution
swarm-benchmark run "Implement JWT authentication for Node.js API" \
--strategy development \
--mode hierarchical \
--quality-threshold 0.9
# Step 3: Create tests
swarm-benchmark run "Write unit tests for JWT authentication" \
--strategy testing
For data analysis tasks:
# Analyze data with collaborative agents
swarm-benchmark run "Analyze user engagement metrics from CSV data" \
--strategy analysis \
--mode mesh \
--quality-threshold 0.95 \
--parallel
For performance improvements:
# Profile and optimize
swarm-benchmark run "Optimize database query performance" \
--strategy optimization \
--mode hybrid \
--monitor \
--profile
Let the system choose the best approach:
# The system analyzes your objective and selects a strategy
swarm-benchmark run "Build a user registration form"
# Auto-selects: development strategy
swarm-benchmark run "Find the best Python web frameworks"
# Auto-selects: research strategy
swarm-benchmark run "Check API response times"
# Auto-selects: testing strategy
Best for information gathering:
# Market research
swarm-benchmark run "Research competitor pricing strategies" \
--strategy research \
--max-agents 8 \
--parallel
# Technical research
swarm-benchmark run "Compare cloud providers for ML workloads" \
--strategy research \
--output json html
For creating code and systems:
# API development
swarm-benchmark run "Create CRUD API for product management" \
--strategy development \
--mode hierarchical \
--review
# Frontend development
swarm-benchmark run "Build React dashboard component" \
--strategy development \
--quality-threshold 0.85
For data processing and insights:
# Business analysis
swarm-benchmark run "Analyze Q4 sales data and identify trends" \
--strategy analysis \
--mode mesh
# Log analysis
swarm-benchmark run "Analyze server logs for error patterns" \
--strategy analysis \
--parallel
For quality assurance:
# API testing
swarm-benchmark run "Create comprehensive test suite for user API" \
--strategy testing \
--mode distributed
# Performance testing
swarm-benchmark run "Load test the checkout process" \
--strategy testing \
--max-agents 10
For performance improvements:
# Code optimization
swarm-benchmark run "Optimize image processing algorithm" \
--strategy optimization \
--profile
# Query optimization
swarm-benchmark run "Optimize slow database queries" \
--strategy optimization \
--monitor
For updates and documentation:
# Documentation
swarm-benchmark run "Update API documentation for v2" \
--strategy maintenance \
--mode centralized
# Refactoring
swarm-benchmark run "Refactor user service to use async/await" \
--strategy maintenance
Best for small teams and straightforward tasks:
# Simple task with few agents
swarm-benchmark run "Create a contact form" \
--mode centralized \
--max-agents 3
For tasks that can be split across multiple coordinators:
# Parallel research across topics
swarm-benchmark run "Research multiple database technologies" \
--mode distributed \
--max-agents 8 \
--parallel
For multi-layered projects with clear structure:
# Large development project
swarm-benchmark run "Build e-commerce platform" \
--mode hierarchical \
--max-agents 10 \
--task-timeout 600
When agents need to work together closely:
# Collaborative code review
swarm-benchmark run "Review and improve codebase architecture" \
--mode mesh \
--max-agents 5 \
--review
Let the system choose the best mode per task:
# Mixed workload
swarm-benchmark run "Complete full project lifecycle" \
--mode hybrid \
--adaptive \
--max-agents 8
Save results in different formats:
# Multiple output formats
swarm-benchmark run "Analyze data" \
--output json sqlite csv \
--output-dir ./analysis-results
# Pretty-printed JSON
swarm-benchmark run "Task" \
--output json \
--pretty-print
# Compressed output
swarm-benchmark run "Large analysis" \
--output json \
--compress
# Export specific benchmark
swarm-benchmark show <id> --format json > benchmark-result.json
# Process results with jq
swarm-benchmark show <id> --format json | \
jq '.results[] | {task: .task_id, time: .execution_time}'
# Generate HTML report
swarm-benchmark show <id> --format report --export report.html
Speed up execution with parallel processing:
# Enable parallel execution
swarm-benchmark run "Process multiple files" \
--parallel \
--max-agents 8
# Parallel with monitoring
swarm-benchmark run "Analyze dataset" \
--parallel \
--monitor \
--metrics-interval 2
Control resource usage:
# Set resource limits
swarm-benchmark run "Resource-intensive task" \
--memory-limit 2048 \
--cpu-limit 75 \
--timeout 30
Run long benchmarks in the background:
# Start in background
swarm-benchmark run "Long analysis task" \
--background \
--name "overnight-analysis"
# Check status later
swarm-benchmark list --filter-name "overnight-analysis"
Ensure high-quality results:
# High quality requirement
swarm-benchmark run "Critical calculation" \
--quality-threshold 0.95 \
--max-retries 5
# With review process
swarm-benchmark run "Important document" \
--quality-threshold 0.9 \
--review \
--testing
Enable strict validation:
# Strict validation
swarm-benchmark run "Generate secure code" \
--validation-mode strict \
--testing
# With automated testing
swarm-benchmark run "Create API endpoints" \
--testing \
--test-coverage 0.8
Watch execution in real-time:
# Basic monitoring
swarm-benchmark run "Long task" --monitor
# Detailed monitoring
swarm-benchmark run "Complex task" \
--monitor \
--verbose \
--metrics-interval 1
Troubleshoot issues:
# Verbose output
swarm-benchmark -v run "Problematic task"
# With execution trace
swarm-benchmark run "Debug this" \
--verbose \
--trace \
--profile
# Dry run to check configuration
swarm-benchmark run "Test configuration" \
--dry-run \
--verbose
Keep your results organized:
# Clean old results
swarm-benchmark clean --older-than 7
# Keep only recent benchmarks
swarm-benchmark clean --keep-recent 50
# Clean by status
swarm-benchmark clean --status failed
Begin with basic commands and add complexity:
# Start here
swarm-benchmark run "Your task"
# Then add strategy
swarm-benchmark run "Your task" --strategy development
# Then optimize
swarm-benchmark run "Your task" \
--strategy development \
--mode hierarchical \
--parallel
Be specific about what you want:
# ❌ Too vague
swarm-benchmark run "Make API"
# ✅ Clear and specific
swarm-benchmark run "Create REST API for user management with JWT authentication"
Always monitor critical benchmarks:
swarm-benchmark run "Production task" \
--monitor \
--quality-threshold 0.9 \
--name "prod-deploy-$(date +%Y%m%d)"
Export and backup critical benchmarks:
# Export important results
swarm-benchmark show --format json \
> backups/benchmark-$(date +%Y%m%d).json
# Compress old results
tar -czf benchmarks-archive.tar.gz ./reports/
For complex or repeated benchmarks:
# benchmark-config.yaml
name: "Daily Analysis"
strategy: analysis
mode: distributed
max_agents: 8
parallel: true
output_formats:
- json
- sqlite
swarm-benchmark -c benchmark-config.yaml run "Daily data analysis"
Now that you understand basic usage:
Happy benchmarking! 🚀