Skip to content

Port benchmark to python#255

Open
tameware wants to merge 10 commits into
dds-bridge:developfrom
tameware:port-benchmark-to-python
Open

Port benchmark to python#255
tameware wants to merge 10 commits into
dds-bridge:developfrom
tameware:port-benchmark-to-python

Conversation

@tameware

Copy link
Copy Markdown
Collaborator

No description provided.

tameware and others added 2 commits July 21, 2026 21:23
Replace the shell implementation with python/tests/benchmark.py, keep
./benchmark.sh as a thin wrapper, and move the dirty-tree git-prep checks
into //python:benchmark_test.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ports the repository’s dtest benchmarking workflow from a large Bash script to a Python implementation, and updates Bazel targets accordingly (including replacing the prior shell-based git-prep test with a Python unit test suite).

Changes:

  • Added a Python benchmark runner (python/tests/benchmark.py) that supports building/checking out branches, running dtest, and producing summary tables.
  • Added stdlib unittest coverage for argument parsing, output parsing, summary formatting, and git branch “dirty tree” gating (python/tests/benchmark_test.py).
  • Updated Bazel setup to expose the benchmark as a py_binary/py_test and removed the previous rules_shell dependency and sh_test.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/tests/benchmark.py New Python benchmark implementation for running and comparing dtest binaries.
python/tests/benchmark_test.py New unit tests covering benchmark logic and git-prep behavior.
python/BUILD.bazel Adds benchmark_lib, benchmark binary, and benchmark_test Bazel targets.
MODULE.bazel Removes direct rules_shell dependency no longer needed after migrating tests.
BUILD.bazel Removes the old sh_test target for benchmark git-prep validation.
benchmark.sh Converts to a thin wrapper invoking the Python benchmark.
benchmark_git_prep_test.sh Removes the old shell-based git-prep test script.

Comment thread python/tests/benchmark.py
Comment thread python/tests/benchmark.py
Comment thread python/tests/benchmark.py
@tameware tameware self-assigned this Jul 22, 2026
@tameware
tameware marked this pull request as ready for review July 22, 2026 03:09
@tameware

tameware commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

I'll address Copilot's open suggestions in a future PR. This one is intended to be a strict port, though in a moment of weakness I did add one divide-by-zero guard.

tameware and others added 3 commits July 23, 2026 00:13
Branch builds overwrite bazel-bin dtest, so that mix could benchmark the wrong executable after restore.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cleanup and main were hardcoding sys.stdout, so a redirected or custom output stream could miss the terminal teardown.

Co-authored-by: Cursor <cursoragent@cursor.com>
run_build was hardcoding sys.stderr, which broke the runner constructor contract for redirected or custom error output.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread python/tests/benchmark.py Outdated
Dropping the whole solver/file row hid partial results; keep the line and omit ratio/note until both sides are available.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread MODULE.bazel

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread python/tests/benchmark.py
Comment thread python/tests/benchmark.py Outdated
@tameware
tameware requested a review from zzcgumn July 23, 2026 20:24
tameware and others added 2 commits July 23, 2026 21:25
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Bazel emits dtest.exe on nt, so the hardcoded dtest path broke the
default baseline and checkout-binary overlap check on Windows.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

python/tests/benchmark.py:719

  • detect_git_branch() calls out to git unconditionally via _git(...). If git is not installed (or not on PATH), this raises FileNotFoundError and crashes even when the user is not using --branch (previous benchmark.sh tolerated missing git and just printed git branch as "unknown"). Catch OSError here and fall back to "unknown".
    def detect_git_branch(self) -> None:
        probe = _git(self.root, "rev-parse", "--is-inside-work-tree", check=False)
        if probe.returncode != 0:
            self.git_branch = "unknown"
            return

Comment thread python/tests/benchmark.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@tameware
tameware requested a review from Copilot July 23, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

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.

3 participants