Skip to content

Add Runner.is_worker() helper - #264

Open
jihtsan wants to merge 1 commit into
psf:mainfrom
jihtsan:codex/166-runner-is-worker
Open

jihtsan wants to merge 1 commit into
psf:mainfrom
jihtsan:codex/166-runner-is-worker

Conversation

@jihtsan

@jihtsan jihtsan commented Oct 14, 2026

Copy link
Copy Markdown

A script collecting results from multiple bench_func() calls also runs in workers, where skipped benchmarks return None. Add the Runner.is_worker() helper requested in #166 so callers can guard result processing such as building a BenchmarkSuite.

The method uses the existing cached argument parser. The API documentation includes a guarded example, and tests cover detection before/after argument parsing plus a real two-benchmark script re-executed in workers. Benchmark execution and return values are unchanged.

Validation on macOS with Python 3.13.12:

  • The original two-benchmark reproducer fails with AttributeError in BenchmarkSuite; the guarded script succeeds and builds the suite only in the main process.
  • All 32 tests in pyperf.tests.test_runner pass, including the two new tests.
  • The full suite ran 177 tests: 176 passed. test_python_option fails because copying this uv-managed interpreter loses its @rpath/libpython3.13.dylib location; the same test fails identically against unmodified HEAD.
  • Sphinx HTML build succeeds with the existing missing static directory warning. Ruff reports the same 14 existing diagnostics in the two Python files before and after the patch, with no new diagnostics. git diff --check passes.

Prepared with Codex assistance.

Refs #166; follows the narrow scope requested after #222 was closed.

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