fresh_cbm.benchmark

Repeatable cache and consumer-projection benchmarks.

class fresh_cbm.benchmark.CacheBenchmark(cache: str, states: int, accounts: int, offsets: int, dtype: str, bytes: int, load_seconds: float, lookup_seconds: float, lookup_repeats: int, blocks: int, cells: int, effect_seconds: float)[source]

Bases: object

Measured cache scale and consumer cost.

Parameters:
  • cache (str) – Cache directory.

  • states (int) – Number of cached stand states.

  • accounts (int) – Account count.

  • offsets (int) – Chain-offset count.

  • dtype (str) – Stored dtype.

  • bytes (int) – Total cache size on disk.

  • load_seconds (float) – Time to load and validate the cache.

  • lookup_seconds (float) – Median random state lookup time.

  • lookup_repeats (int) – Lookup repetitions.

  • blocks (int) – Blocks in the effect projection.

  • cells (int) – Target cells in the projection.

  • effect_seconds (float) – Time to project the blocks onto the cells.

fresh_cbm.benchmark.benchmark_cache(cache_path: str | Path, fragments: DataFrame, chains: Mapping[int, tuple[tuple[str, int], ...]], cells: Sequence[tuple[int, str]], *, repeats: int = 100, seed: int = 7) → CacheBenchmark[source]

Measure load, lookup, projection, and storage.

Parameters:
  • cache_path (path-like) – Cache directory.

  • fragments (pandas.DataFrame) – Block/fragment rows for the projection.

  • chains (mapping of int to tuple) – Current chain per block.

  • cells (sequence of (int, str)) – Target cells.

  • repeats (int, optional) – Random lookup repetitions. Defaults to 100.

  • seed (int, optional) – Random seed. Defaults to seven.

Returns:

CacheBenchmark – The measured result.

fresh_cbm.benchmark.main(argv: Sequence[str] | None = None) → int[source]

Run the cache benchmark from the command line.

Parameters:

argv (sequence of str or None, optional) – Command-line arguments. None reads sys.argv.

Returns:

int – Process exit status.