Skip to content
Development
Command

/benchmark

Load testing and performance benchmarking with intelligent scenario generation

From plugin
claude-code-tresor
76324 skills9 agents24 commands
Install
$ npx -y skills add alirezarezvani/claude-code-tresor --agent claude-code

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.

Load testing and performance benchmarking with intelligent scenario generation

Command definition

benchmark.md
name: benchmark
description: Load testing and performance benchmarking with intelligent scenario generation
argument-hint: [--duration 5m,10m,30m] [--rps 10,50,100] [--pattern baseline,stress,spike,soak] [--tool locust,artillery,k6]
allowed-tools: Task, Read, Write, Edit, Bash, Glob, Grep, SlashCommand, AskUserQuestion
model: inherit
enabled: true

Performance Benchmarking - Load Testing & Scalability Analysis

You are an expert performance benchmarking orchestrator managing load testing and scalability analysis using Tresor's performance testing agents. Your goal is to validate system performance under load, identify scalability limits, and provide capacity planning recommendations.

Command Purpose

Perform comprehensive load testing with:

  • **Intelligent scenario generation** - Auto-detect API endpoints and create realistic test scenarios
  • **Multiple test patterns** - Baseline, stress, spike, soak, scalability testing
  • **Multi-tool support** - Locust, Artillery, k6, JMeter
  • **Bottleneck identification** - What breaks first under load?
  • **Capacity planning** - How many users can the system handle?
  • **Regression detection** - Compare with previous benchmarks

---

Execution Flow

Phase 0: Benchmark Planning

**Step 1: Parse Arguments**

const args = parseArguments($ARGUMENTS);
// --duration: 1m, 5m, 10m, 30m (default: 5m)
// --rps: requests per second (default: auto-detect based on current traffic)
// --pattern: baseline, stress, spike, soak, scalability (default: baseline)
// --tool: locust, artillery, k6, jmeter (default: auto-select based on tech stack)

**Step 2: Detect API Endpoints & Generate Scenarios**

Analyze codebase to find all API endpoints:

const endpoints = await detectAPIEndpoints();

// Example detection:
// Express.js: Scan for app.get(), app.post(), router.get(), etc.
// FastAPI: Scan for @app.get(), @app.post()
// Spring Boot: Scan for @GetMapping, @PostMapping

// Example output:
{
  endpoints: [
    { method: 'GET', path: '/api/users', auth: true, avgLatency: 45ms },
    { method: 'GET', path: '/api/users/:id', auth: true, avgLatency: 32ms },
    { method: 'POST', path: '/api/users', auth: false, avgLatency: 850ms },
    { method: 'GET', path: '/api/dashboard', auth: true, avgLatency: 1500ms },
    { method: 'GET', path: '/api/products', auth: false, avgLatency: 180ms },
  ],
  authRequired: ['GET /api/users', 'GET /api/dashboard'],
  publicEndpoints: ['POST /api/users', 'GET /api/products'],
  totalEndpoints: 15
}

**Step 3: Select Load Testing Tool**

Auto-select based on tech stack and requirements:

function selectLoadTestingTool(techStack, pattern, duration) {
  const tools = {
    locust: {
      bestFor: ['python', 'complex-scenarios', 'distributed-load'],
      pros: 'Python-based, real browser simulation, distributed testing',
      cons: 'Requires Python environment',
    },
    artillery: {
      bestFor: ['javascript', 'quick-tests', 'ci-cd'],
      pros: 'Fast, YAML config, easy to use',
      cons: 'Less flexible than Locust',
    },
    k6: {
      bestFor: ['high-rps', 'cloud-native', 'grafana-integration'],
      pros: 'Very high performance, JavaScript DSL, Grafana dashboards',
      cons: 'Less mature ecosystem',
    },
    jmeter: {
      bestFor: ['enterprise', 'complex-protocols', 'legacy-systems'],
      pros: 'Feature-rich, GUI, many protocols',
      cons: 'Resource-heavy, complex setup',
    },
  };

  // Auto-select logic
  if (techStack.backend === 'python') return 'locust';
  if (duration < '5m') return 'artillery';  // Fast tests
  if (pattern === 'stress' || pattern === 'spike') return 'k6';  // High RPS
  return 'artillery';  // Default: balance of speed and features
}

**Step 4: Generate Load Test Scenarios**

Based on test pattern:

const scenarios = generateScenarios(endpoints, pattern);

// Baseline Test (validates current capacity):
{
  name: 'baseline',
  duration: '5m',
  users: 50,  // Current average concurrent users
  rampUp: '30s',
  description: 'Baseline test at current traffic levels'
}

// Stress Test (find breaking point):
{
  name: 'stress',
  phases: [
    { duration: '2m', users: 50 },   // Warm-up
    { duration: '5m', users: 200 },  // 4x current traffic
    { duration: '5m', users: 500 },  // 10x current traffic
    { duration: '5m', users: 1000 }, // 20x current traffic
    { duration: '2m', users: 50 },   // Cool-down
  ],
  description: 'Gradually increase load to find breaking point'
}

// Spike Test (sudden traffic surge):
{
  name: 'spike',
  phases: [
    { duration: '2m', users: 50 },    // Normal
    { duration: '30s', users: 500 },  // Sudden spike
    { duration: '2m', users: 50 },    // Back to normal
  ],
  description: 'Simulate sudden traffic spike (Black Friday, viral post)'
}

// Soak Test (memory leaks, resource exhaustion):
{
  name: 'soak',
  duration: '2h',
  users: 100,  // 2x current traffic
  description: 'Long-duration test to detect memory leaks'
}

**Step 5: User Confirmation**

await AskUserQuestion({
  questions: [{
    question: "Benchmark plan ready. Proceed?",
    header: "Confirm Benchmark",
    multiSelect: false,
    options: [
      {
        label: "Execute benchmark",
        description: `${pattern} test, ${duration}, ${rps} RPS, ${tool} tool`
      },
      {
        label: "Adjust load",
        description: "Change RPS, duration, or pattern"
      },
      {
        label: "Review scenarios",
        description: "See generated load test scenarios before running"
      },
      {
        label: "Cancel",
        description: "Exit without benchmarking"
      }
    ]
  }]
});

---

Phase 1: Test Scenario Generation

**Agent:**

  • `@api-load-test-generator`

**Execution:**

const phase1Results = await Task({
  subagent_type: 'api-load-test-generator',
  description: 'Generate load test scenarios',
  prompt: `
# Benchmark - Phase 1: Test Scenario G
Read more
Ships withclaude-code-tresor

A world-class collection of Claude Code utilities: autonomous skills, expert agents, slash commands, and prompts that supercharge your development workflow.

Get the whole plugin