Skip to content
Back to skills

Optimize

ASecurity

Benchmark, analyze, and optimize a function's execution time. Produces a before/after performance table with real numbers. Never presents a change without proving it is faster.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 26, 2026
code-qualitygobashrefactoringperformance

Works with

  • terminal

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add v0idOS/performance-deity --skill optimize --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Optimize?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Optimize
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/v0idos-optimize/badge)](https://www.skillsdirectory.com/skills/v0idos-optimize)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Benchmark, analyze, and optimize a function's execution time. Produces a before/after performance table with real numbers. Never presents a change without proving it is faster.
---

Execute all four phases in order. Do not skip any phase.

## Phase 1 — Establish Baseline

1. Identify the exact code to optimize.
2. Run a micro-benchmark:
   - Write a temporary micro-benchmark script in the user's workspace.
   - The script MUST contain a warm-up phase (discard ≥10 iterations).
   - The script MUST run ≥100 iterations and output the Average and P95 execution time.
   - Run the script using the terminal.
   - Delete the temporary script after recording the results.
   - *Note: If the script fails due to missing imports or dependencies, skip it and use the bash `time` command as a fallback.*
3. Record P95 and Average. Do not proceed until the benchmark runs without error.
4. Report baseline numbers before writing any new code.

## Phase 2 — Algorithmic Analysis

1. State the current Time Complexity (Big-O) explicitly.
2. State the current Space Complexity and identify the primary allocation sites.
3. Name the bottleneck precisely:
   - "Nested loops causing O(n²) scaling"
   - "Repeated string concatenation causing N heap allocations per call"
   - "Full table scan caused by missing index on `user_id`"

## Phase 3 — Refactoring

1. Rewrite using a more efficient algorithm or data structure (apply in priority order):
   - Replace Array/List lookups with Hash Sets/Dictionaries: O(N) → O(1)
   - Vectorization or batching instead of per-item iteration
   - Caching/memoization of expensive pure computations
   - Zero-allocation patterns and buffer reuse to reduce GC pressure
   - Bitwise operations where mathematically equivalent
2. Run the benchmark on the new code.
3. If the new code is not measurably faster: discard it, select a different approach, repeat.

## Phase 4 — Report

Present a Performance Report table:

| Metric | Baseline | Optimized | Δ |
|---|---|---|---|
| Average | Xms | Yms | -Z% |
| P95 | Xms | Yms | -Z% |

Follow with a one-paragraph explanation grounded in CPU/memory theory.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.