feat: benchmem compare --format md (GitHub-flavored markdown table)#147
Open
FBumann wants to merge 1 commit into
Open
feat: benchmem compare --format md (GitHub-flavored markdown table)#147FBumann wants to merge 1 commit into
benchmem compare --format md (GitHub-flavored markdown table)#147FBumann wants to merge 1 commit into
Conversation
`compare` could only render the rich terminal table (or `--csv` raw values); there was no readable artifact to drop into a PR comment / $GITHUB_STEP_SUMMARY, the natural companion to --fail-on and CodSpeed-style CI. Add `--format table|md`: `md` emits a native GFM table to stdout. It's plain by design — values + the existing `(N.NN)` multiplier, which already carries best (1.0) and magnitude — no colour (GFM strips inline styles) and no emoji (that would bake an opinion into everyone's comments); the multiplier is the signal. Refactored so both formats render one shared model: `_build_views` computes the per-group rows + byte-scaled columns + best/worst once, and `_render_rich` / `_render_markdown` only differ in emit. The fiddly value math (`_scale_columns`, `_cell_body`, `_mult`, `_row_label`) is shared, so the formats can't drift; the rich output is byte-identical (existing tests unchanged). Docs note the three readable paths (--format md, > out.txt, --csv). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
--format table|mdtobenchmem compare.mdemits a native GitHub-flavored markdown table to stdout — the readable artifact to pipe into a PR comment or$GITHUB_STEP_SUMMARY, the natural companion to--fail-on/ CodSpeed-style CI. Default stays the rich terminal table;--csv(raw values) is unchanged.pkg::test_x
Design — deliberately un-opinionated
It's plain: values + the existing
(N.NN)multiplier. We discussed colour/emoji and dropped both:<span style>), so terminal-style colour can't carry over on GitHub anyway.🔴/🟢) would render, but it's content in the cell — can't be stripped, varies by font, has accessibility cost, and bakes one aesthetic into everyone's comments.(N.NN)multiplier already encodes what colour did:(1.0)is the best, larger is worse, and it's magnitude not just rank. So plain markdown loses nothing essential.(
> out.txtalready gives a clean monospace table for code fences;--format mdadds the natively-rendered GitHub table. Both documented.)DRY refactor
Split the per-group table model from the renderers so the two formats can't drift:
_build_viewscomputes, once, each group's ordered rows + byte-scaled columns (_scale_columns) + best/worst._render_richand_render_markdowndiffer only in emit; the value math (_cell_body,_mult,_row_label,byte_unit) is shared.comparetests pass unchanged.mdskips the timed│untimed divider (not a real column) and escapes|in cells.Tests & docs
New tests: GFM table shape (heading / header / alignment / multiplier / no-ANSI-no-box-chars), pipe-escaping in a multi-id row cell, unknown-format error, and a CLI
--format mdtest. Full suite green (291); ruff format+check clean; mypy clean. Docs gain a "Sharing the table" note covering--format md/> out.txt/--csv.🤖 Generated with Claude Code