Skip to content

feat: add per-stage compression stats table formatter#20

Open
hugoni-va wants to merge 1 commit intoopen-compress:mainfrom
hugoni-va:perf/add-compression-stats-breakdown
Open

feat: add per-stage compression stats table formatter#20
hugoni-va wants to merge 1 commit intoopen-compress:mainfrom
hugoni-va:perf/add-compression-stats-breakdown

Conversation

@hugoni-va
Copy link
Copy Markdown

Summary

The engine already collects per-stage stats (original_tokens, compressed_tokens, timing_ms) but there is no built-in way to display them in a human-readable format. This is useful when tuning compression for a specific content type.

Changes

  • New module claw_compactor.fusion.stats_formatter with format_stats_table(stats) function
  • Takes the stats dict from engine.compress() and returns a formatted table string
  • Optional show_skipped=True to include stages that did not fire
  • Includes totals row with overall compression percentage

Usage

from claw_compactor.fusion.engine import FusionEngine
from claw_compactor.fusion.stats_formatter import format_stats_table

engine = FusionEngine()
result, stats, markers, warnings = engine.compress(text)
print(format_stats_table(stats))

Adds a format_stats_table() utility that renders the per_stage stats
dict as a clean CLI table showing token counts, reduction percentage,
and timing for each pipeline stage. Useful for debugging which stages
are contributing the most compression and identifying bottlenecks.

Example output:

  Stage             Before    After    Saved      %       ms
  ──────────────────────────────────────────────────────────
  RLE                4,200    3,800      400   10.0%     2.1
  SemanticDedup      3,800    3,200      600   15.8%     4.3
  Ionizer            3,200    1,100    2,100   65.6%     8.7
  Total              4,200    1,050    3,150   75.0%    18.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant