agentleFS
narenaryannarenaryan/agent-skills/skills/python/python-scaling-regression-tests/SKILL.md

python-scaling-regression-tests

Skill0 starsChanged 39 days agoMITView on GitHub

Use when Python code remains fast on small fixtures but slows disproportionately with input size, or a refactor may turn a linear algorithm quadratic; applies to empirical complexity regression tests, size-function design, and bigO measurement isolation.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Test how cost grows, separately from how many milliseconds one execution takes.

    line 8
  2. Very specific:

    Use a dedicated performance-test process.

    line 21
  3. Distinctive:

    Before trusting the gate, temporarily substitute a behavior-equivalent quadratic implementation and confirm rejection.

    line 43
  4. Distinctive:

    Do not fix flaky results by silently weakening the bound.

    line 52

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python Scaling Regression Tests

Test how cost grows, separately from how many milliseconds one execution takes. A faster implementation can still have a worse growth curve. An empirical fit is evidence over sampled inputs, not an asymptotic proof.

Choose the experiment

DecisionConstraint
Size functionRepresent the work-driving dimension; use constant-time metadata such as len(a) + len(b), not a traversal
Input familyExercise meaningful sizes and distributions; separate early-exit, worst-case, and duplicate-heavy cases
Timing boundaryConstruct fixtures outside the measured function; include copying only when copying is part of its contract
ClaimPair growth checks with output assertions; keep absolute-latency budgets separate

Isolated bound check

Use a dedicated performance-test process. The upstream plasma-umass/bigO API checked on 2026-10-04 exposes assert_bounds and disable_persistence; verify the project's pinned dependency.

from bigO import assert_bounds, disable_persistence

disable_persistence()  # Dedicated test process: suppress exit-time JSON writes.

def unique_count(values):
    seen = set()
    for value in values:
        seen.add(value)
    return len(seen)

def test_unique_count_scaling():
    samples = [(list(range(n)),) for n in range(2_000, 82_000, 2_000)]
    assert unique_count([2, 2, 5]) == 2
    assert_bounds(unique_count, lambda values: len(values), samples,
                  time="O(n)")

assert_bounds clears prior in-memory measurements. A short no_persistence() block restores the save flag afterward, so it does not prevent later exit-time writes. For exploratory track runs, use a fresh directory so accumulated bigO_data.json cannot mix experiments.

Before trusting the gate, temporarily substitute a behavior-equivalent quadratic implementation and confirm rejection. Repeat the unchanged baseline to check noise sensitivity; restore the real implementation afterward. Record the dependency version and input family with the result.

Sources: Python⇒Speed, 2026-01-07, upstream API and caveats, checked implementation.

Pitfalls

  • One size or tiny inputs can hide a growth change beneath call overhead.
  • A passing bound misses constant-factor slowdowns and untested input distributions.
  • Concurrent calls are outside bigO's supported measurement model; isolate the benchmark.
  • Do not fix flaky results by silently weakening the bound. Inspect samples, environment noise, and the chosen size metric first.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.