All skills

Set up and run performance tests (profiling, load testing, or E2E scenarios), preserving occasional manual procedures and results for future repetition. Use when measuring code or endpoint performance, or before/after optimization work.

Use this Skill: https://skilld.dev/gh/nielsmadan/agentic-coding/perf-test

This session only. Nothing lands on disk.

referencestemplates.md

≈834 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Performance Test Templates

Language-specific benchmark templates, load testing configs, and E2E scenario examples.

Code Profiling by Language

JavaScript/TypeScript

// perf-tests/{target}.bench.js
const Benchmark = require('benchmark');
const suite = new Benchmark.Suite;

suite
  .add('{functionName}', function() {
    // code to benchmark
  })
  .on('complete', function() {
    console.log(this[0].toString());
    console.log('ops/sec:', this[0].hz);
  })
  .run();

Python

# perf-tests/{target}_bench.py
import timeit
import statistics

def benchmark():
    times = timeit.repeat(
        '{function_call}',
        setup='{setup_code}',
        number=1000,
        repeat=5
    )
    print(f"Mean: {statistics.mean(times):.4f}s")
    print(f"Stdev: {statistics.stdev(times):.4f}s")

Go

// {target}_test.go
func Benchmark{Function}(b *testing.B) {
    for i := 0; i < b.N; i++ {
        // code to benchmark
    }
}

Load Testing

Using hey (universal)

hey -n 1000 -c 50 -m GET http://localhost:3000/api/endpoint

Using autocannon (Node.js)

const autocannon = require('autocannon');
autocannon({
  url: 'http://localhost:3000/api/endpoint',
  connections: 50,
  duration: 10
}, console.log);

E2E Scenario Testing

For testing real-world workflows involving multiple operations and state changes.

1. Setup Phase

// Create known database state
async function setupTestState() {
  await db.reset();
  await db.seed({
    users: [{ id: 'user_1', balance: 1000 }],
    products: [{ id: 'prod_1', stock: 100, price: 25 }],
    carts: []
  });
}

2. Scenario Script

// e2e-perf/checkout-flow.js
const { performance } = require('perf_hooks');

async function runScenario() {
  const metrics = { steps: [], total: 0 };
  const start = performance.now();

  // Step 1: Add items to cart
  let stepStart = performance.now();
  await fetch('/api/cart/add', {
    method: 'POST',
    body: JSON.stringify({ productId: 'prod_1', quantity: 2 })
  });
  metrics.steps.push({ name: 'add_to_cart', ms: performance.now() - stepStart });

  // Step 2: Apply discount code
  stepStart = performance.now();
  await fetch('/api/cart/discount', {
    method: 'POST',
    body: JSON.stringify({ code: 'SAVE10' })
  });
  metrics.steps.push({ name: 'apply_discount', ms: performance.now() - stepStart });

  // Step 3: Checkout
  stepStart = performance.now();
  await fetch('/api/checkout', { method: 'POST' });
  metrics.steps.push({ name: 'checkout', ms: performance.now() - stepStart });

  metrics.total = performance.now() - start;
  return metrics;
}

// Run multiple iterations
async function benchmark(iterations = 100) {
  const results = [];
  for (let i = 0; i < iterations; i++) {
    await setupTestState(); // Reset state each run
    results.push(await runScenario());
  }
  return analyzeResults(results);
}

3. Cleanup

async function cleanup() {
  await db.reset();
  // Or restore to known good state
}

Key Considerations

  • Isolate test database (don't use production)
  • Reset state between iterations for consistency
  • Measure individual steps AND total time
  • Account for cold starts vs warm runs
  • Consider concurrent users for realistic load

Source: SKILL.md on GitHub

No alerts6mo3 checks · Risk SAFE
  • Gen Agent Trust Hub6mo

    No security issues detected. The skill provides a structured workflow for performance testing, including code profiling, load testing, and end-to-end scenarios using standard industry tools.

  • Socket6mo

    No alerts

  • Snyk6mo

    Risk: LOW · No issues

Signed by skilld at b4803ea. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 weeks ago
argument-hint
<target: file, function, endpoint, or service>
effort
high

README badge

README badge for nielsmadan/agentic-coding/perf-test