Use this skill to measure performance baselines, detect regressions before/after PRs, and compare stack alternatives.
git clone https://github.com/affaan-m/ECC.git--- name: benchmark description: Use this skill to measure performance baselines, detect regressions before/after PRs, and compare stack alternatives. license: MIT metadata: origin: ECC --- # Benchmark — Performance Baseline & Regression Detection ## When to Use - Before and after a PR to measure performance impact - Setting up performance baselines for a project - When users report "it feels slow" - Before a launch — ensure you meet performance targets - Comparing your stack against alternatives ## How It Works ### Mode 1: Page Performance Measures real browser metrics via browser MCP: ``` 1. Navigate to each target URL 2. Measure Core Web Vitals: - LCP (Largest Contentful Paint) — target < 2.5s - CLS (Cumulative Layout Shift) — target < 0.1 - INP (Interaction to Next Paint) — target < 200ms - FCP (First Contentful Paint) — target < 1.8s - TTFB (Time to First Byte) — target < 800ms 3. Measure resource sizes: - Total page weight (target < 1MB) - JS bundle size (target < 200KB gzipped) - CSS size - Image weight - Third-party script weight 4. Count network requests 5. Check for render-blocking resources ``` ### Mode 2: API Performance Benchmarks API endpoints: ``` 1. Hit each endpoint 100 times 2. Measure: p50, p95, p99 latency 3. Track: response size, status codes 4. Test under load: 10 concurrent requests 5. Compare against SLA targets ``` ### Mode 3: Build Performance Measures development feedback loop: ``` 1. Cold build time 2. Hot reload time (HMR) 3. Test suite duration 4. TypeScript check time 5. Lint time 6. Docker build time ``` ### Mode 4: Before/After Comparison Run before and after a change to measure impact: ``` /benchmark baseline # saves current metrics # ... make changes ... /benchmark compare # compares against baseline ``` Output: ``` | Metric | Before | After | Delta | Verdict | |--------|--------|-------|-------|---------| | LCP | 1.2s | 1.4s | +200ms | WARNING: WARN | | Bundle | 180KB | 175KB | -5KB | ✓ BETTER | | Build | 12s | 14s | +2s | WARNING: WARN | ``` ## Output Stores baselines in `.ecc/benchmarks/` as JSON. Git-tracked so the team shares baselines. ## Integration - CI: run `/benchmark compare` on every PR - Pair with `/canary-watch` for post-deploy monitoring - Pair with `/browser-qa` for full pre-ship checklist
1. **Define Your Benchmark Scope:** Specify the system, tool, and metrics you want to measure (e.g., 'Benchmark PostgreSQL query performance using `pgbench` with 1000 concurrent connections'). 2. **Set Up the Environment:** Ensure the system under test is isolated (e.g., no background processes) and the benchmark tool is configured correctly (e.g., warm-up runs, iterations, and load profiles). 3. **Run Baseline Tests:** Execute the benchmark on the current state (e.g., 'Run `hyperfine --warmup 3 'python script.py'` for the baseline'). 4. **Apply Changes and Re-run:** Introduce your changes (e.g., code updates, config tweaks) and repeat the benchmark using the same parameters. 5. **Analyze and Compare:** Use the output to identify regressions or improvements. Focus on statistically significant changes and correlate them with code/commit history. **Tips:** - Use `--warmup` in tools like Hyperfine to stabilize results. - For CI/CD integration, automate benchmarks in your pipeline (e.g., GitHub Actions) and fail builds if regressions exceed a threshold. - Normalize metrics (e.g., latency per request) when comparing across different hardware or environments.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/affaan-m/ECC/tree/main/skills/benchmarkCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Benchmark [SYSTEM/COMPONENT/ALGORITHM] using [TOOL: e.g., Hyperfine, JMH, k6, or custom script]. Measure [METRICS: e.g., latency, throughput, memory usage, CPU utilization] under [LOAD: e.g., 1000 RPS, 100 concurrent users, 1GB dataset]. Compare results against [BASELINE: e.g., previous commit, competitor solution, or theoretical max]. Provide a summary of regressions or improvements, including statistical significance where applicable. Include raw data in a table format for easy analysis.
### Benchmark Results: API Response Latency Comparison **System Under Test:** FastAPI v0.104.1 (Python 3.11) running on an AWS EC2 `t3.medium` instance (2 vCPUs, 4GB RAM). **Tool Used:** `k6` v0.47.0 with 1000 virtual users (RPS) over 5 minutes. **Metrics Tracked:** P99 latency (ms), average latency (ms), error rate (%), and throughput (RPS). | Metric | Baseline (v0.103.0) | Current (v0.104.1) | Change (%) | Statistical Significance (p < 0.05) | |----------------------|----------------------|---------------------|------------|--------------------------------------| | P99 Latency | 125 ms | 142 ms | +13.6% | Significant | | Average Latency | 42 ms | 58 ms | +38.1% | Significant | | Error Rate | 0.1% | 0.3% | +200% | Significant | | Throughput (RPS) | 980 | 890 | -9.2% | Significant | **Key Findings:** The upgrade to v0.104.1 introduced a **regression in latency and throughput**, with P99 latency increasing by 17ms and average latency spiking by 16ms. The error rate tripled, likely due to a new middleware integration that wasn't optimized for high load. Memory usage also increased by 15% (from 1.2GB to 1.38GB), though this did not trigger OOM errors. **Recommendations:** 1. **Rollback or Patch:** Revert to v0.103.0 until the regression is resolved, or apply a hotfix targeting the new middleware. 2. **Load Testing:** Run additional tests with 5000 RPS to determine if the regression scales linearly. 3. **Profiling:** Use `py-spy` to identify bottlenecks in the new code paths introduced in v0.104.1. **Raw Data:** ``` Baseline (v0.103.0): - P99 Latency: 125ms, Avg: 42ms, Errors: 0.1%, RPS: 980 - Memory: 1.2GB (stable) Current (v0.104.1): - P99 Latency: 142ms, Avg: 58ms, Errors: 0.3%, RPS: 890 - Memory: 1.38GB (stable) ```
skills-collection
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan