Skip to content

About

Cocapn fleet benchmark module

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

cocapn-benchmark — Fleet Performance Testing

Benchmark fleet packages, detect regressions, profile edge hardware. Pure Python.

What This Gives You

  • Timer benchmarks — high-resolution timing with statistical analysis (mean, median, p95, p99, std dev)
  • Memory profiling — track memory allocation during benchmark runs
  • Benchmark suites — group and run benchmarks together with setup/teardown lifecycle
  • Regression detection — compare runs against baselines, flag regressions automatically
  • Edge profiler — profile performance on edge/constrained hardware targets
  • Comparison reports — side-by-side results in markdown, JSON, or terminal tables

Quick Start

pip install cocapn-benchmark
from cocapn_benchmark import Benchmark, BenchmarkSuite, BenchmarkReport

# Benchmark a function
bench = Benchmark("json_parse", lambda: __import__("json").loads('{"key": "value"}'))
bench.run()
print(bench.result)  # BenchmarkResult with timing stats

# Build a suite
suite = BenchmarkSuite("fleet-core")
suite.add(Benchmark("tile_create", lambda: Tile("Q", "A")))
suite.add(Benchmark("room_query", lambda: room.ask("test")))
results = suite.run_all()

# Generate a report
report = BenchmarkReport(suite_results=results)
print(report.to_markdown())

# Regression check
from cocapn_benchmark import RegressionConfig
config = RegressionConfig(max_slowdown_pct=10.0)
regressions = report.check_regressions(baseline, config)

API Reference

Benchmark(name, fn, config=None)

Runs fn through setup → warmup → measurement → teardown.

BenchmarkConfig(iterations=100, warmup=5, track_memory=False)

BenchmarkSuite(name) — Group benchmarks, run together

BenchmarkReport — Markdown/JSON report generation

RegressionConfig — Threshold-based regression detection

EdgeProfiler — Constrained-device profiling

Timer — Raw high-resolution timer

MemorySnapshot — Memory tracking

How It Fits

Performance backbone for the SuperInstance fleet. Every package runs through cocapn-benchmark before release.

Testing

pip install pytest
pytest tests/

Installation

pip install cocapn-benchmark

Python 3.10+. MIT license.

About

Cocapn fleet benchmark module

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages