benchmark-before-optimize

benchmark-before-optimize is a skill for Claude Code from jimmc414/claude-code-plugin-marketplace. It costs 25 tokens per session (805 once invoked), scanned A, original, MIT.

A performance-testing pattern that measures code before and after changes and uses profiling to locate slow parts.

In plain words
What is it for?
Use it to compare algorithms, find bottlenecks, and validate performance improvements.
Why use it?
It helps confirm whether an optimization actually improves performance and prevents changes based only on guesses.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the norvig-patterns plugin — 54 skills shipped together

Good fit Use it to compare algorithms, find bottlenecks, and validate performance improvements.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jimmc414/claude-code-plugin-marketplace/benchmark-before-optimize
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add jimmc414/claude-code-plugin-marketplace --skill benchmark-before-optimize
Clone the repo
git clone --depth 1 https://github.com/jimmc414/claude-code-plugin-marketplace

Made for: Claude Code.

Or install norvig-patterns, the plugin that ships this one along with the rest of its 54 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for benchmark-before-optimize

README.md
[![agentmods](https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/benchmark-before-optimize/github.svg)](https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/benchmark-before-optimize)
Your own site
<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/benchmark-before-optimize"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/benchmark-before-optimize/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for benchmark-before-optimize

Your own site · 80×15
<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/benchmark-before-optimize"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/benchmark-before-optimize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 805 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00025 $0.00805
Opus 5.5 $0.00010 $0.00322
Sonnet 5.5 $0.00005 $0.00161
Haiku 4.5 $0.00003 $0.00081

Measured 1mo ago against content hash cd94aa9d349e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

benchmark-before-optimize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/norvig-patterns/skills/benchmark-before-optimize/SKILL.md · 104 lines

How it starts

The opening of the file, as written. The whole thing — 104 lines — stays where its author put it; the contents beside it link to each section on GitHub.

benchmark-before-optimize

When to Use

  • Before attempting optimization
  • Comparing algorithm implementations
  • Finding bottlenecks
  • Validating performance improvements

When NOT to Use

  • Obvious micro-optimizations
  • Code that runs once
  • When correctness is more important

The Pattern

Measure performance with timing and profiling before making changes.

import time

def time_it(func, *args, **kwargs):
    """Time a single function call."""
    start = time.process_time()
    result = func(*args, **kwargs)
    elapsed = time.process_time() - start
    return result, elapsed

def benchmark(func, inputs, name=""):
    """Benchmark function on multiple inputs."""
    times = []
    for inp in inputs:
        _, elapsed = time_it(func, inp)
        times.append(elapsed)

    print(f"{name}: avg={sum(times)/len(times):.4f}s, "
          f"max={max(times):.4f}s, "
          f"total={sum(times):.4f}s")

Example (from pytudes)

# sudoku.py - comprehensive benchmarking
import time

def time_solve(grid):
    """Time how long it takes to solve a grid."""
    start = time.process_time()
    values = solve(grid)
    t = time.process_time() - start
    return (t, solved(values))

def solve_all(grids, name=''):
    """Attempt to solve grids and report statistics."""
    times, results = zip(*[time_solve(grid) for grid in grids])
    N = len(results)
    if N > 1:
        print("Solved %d of %d %s puzzles "
              "(avg %.2f secs (%d Hz), max %.2f secs)." % (
            sum(results), N, name,
            sum(times)/N, N/sum(times), max(times)))

if __name__ == '__main__':
    solve_all(open("sudoku-easy50.txt"), "easy")
    solve_all(open("sudoku-top95.txt"), "hard")
    solve_all(open("sudoku-hardest.txt"), "hardest")

# spell.py - throughput measurement
def spelltest(tests, verbose=False):
    """Run correction on all (right, wrong) pairs; report results."""
    import time
    start = time.process_time()
    good, unknown = 0, 0
    n = len(tests)

    for right, wrong in tests:
        w = correction(wrong)
        good += (w == right)
        if w != right:
            unknown += (right not in WORDS)

    dt = time.process_time() - start
    print('{:.0%} of {} correct ({:.0%} unknown) at {:.0f} words per second'
          .format(good / n, n, unknown / n, n / dt))

# Cryptarithmetic.ipynb - profiling with %prun
%prun first(solve('NUM + BER = PLAY'))
# Output shows where time is spent:
#    ncalls  tottime  percall  cumtime  filename:lineno(function)
#    309270    1.779    0.000    1.833  {built-in method builtins.eval}

Read the full file on GitHub · 104 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 104 lines · 25 tokens per session scan A cd94aa9d349e

Subscribe to this mod's changes

benchmark-before-optimize is a skill published in the GitHub repository jimmc414/claude-code-plugin-marketplace (4 stars, last pushed yesterday), licensed MIT. It adds 25 tokens to every session and 805 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

drive

Launch and operate the project's app, observe it and record evidence, without judging it. Actions: drive a feature, ready (what is reachable), capture one artifact, cleanup. Use when another skill, a scheduled run or a CI job needs the real app run and shown (/verification:confirm, /debugging:debug), or when asked to…

melodic-software/claude-code-plugins · 92 tokens

audit-dead-code

Read-only hunt for dead and unused code across four labeled lanes (Knip for TS/JS, vulture for Python, gopls for Go, grep for shell and files no lane owns), each candidate adjudicated dead, uncertain or alive. Use when asked to 'find dead code', to find what is unused in a repository (exports, functions, orphaned…

melodic-software/claude-code-plugins · 99 tokens

generate-file-name-gate

Emit the file-name gate into a consuming repository: a standalone bash checker plus its own test suite, with the casing rule, roots, and exemptions inlined from the resolved docs-naming configuration, and optionally the path-scoped rule file. The emitted pair carries no dependency on this plugin at run time. Refuses…

melodic-software/claude-code-plugins · 143 tokens

devils-advocate

Stress-test plans and proposals via systematic adversarial review. Assumption extraction, evidence check, failure scenarios, operational gotchas. Before implementation begins. Use when: asked to attack a plan or proposal ('devil's advocate', 'stress test', 'poke holes', 'what could go wrong'), or before implementation…

melodic-software/claude-code-plugins · 139 tokens

methodology

When the bundled claude-api skill resolves in this session, prefer its hillclimb for sweeping model and effort against an existing eval suite; this skill when the suite does not exist yet or its criteria are not yet measurable, before handing the suite to that search. Answers LLM-evaluation design questions from…

melodic-software/claude-code-plugins · 221 tokens

known-issues

Lookup and tracking of known Claude product issues: GitHub bug search, service health and model quality checks, and a persistent registry of tracked issues. Use when: 'is this broken', 'any workarounds', 'troubleshoot Claude Code', 'feature behaves unexpectedly', 'scan repo for issues', 'file a bug'. Actions: status…

melodic-software/claude-code-plugins · 86 tokens