Report Test Cycles in PyTest and the CI Job Summary - #207
Conversation
run_and_assert_test already had the parsed cycle count in its TestResult and dropped it. Print it on a canonical marker line -- before the assertions, so a failing test still reports -- and collect those in conftest. The collection runs in pytest_runtest_logreport, which fires on the xdist master for every worker's report; a module-level list filled inside the tests would stay in the worker process and never reach the summary. The terminal hook does run in the workers too, each holding only its own tests, so writing the job summary is guarded to the master -- otherwise every worker appends its own partial table to the same shared file.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe test utilities now emit runtime-cycle markers. Pytest collects these markers from passed and failed tests, prints sorted results, and can append a performance table to the GitHub Actions job summary. The changelog documents the feature. ChangesPerformance reporting
Merge Risk: ⚪ Minimal · up to This PR adds runtime-cycle reporting to test output and GitHub Actions summaries without changing product behavior; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant run_and_assert_test
participant pytest_runtest_logreport
participant pytest_terminal_summary
participant GITHUB_STEP_SUMMARY
run_and_assert_test->>pytest_runtest_logreport: emit and collect runtime cycle marker
pytest_runtest_logreport->>pytest_terminal_summary: aggregate performance results
pytest_terminal_summary->>GITHUB_STEP_SUMMARY: append Markdown performance table
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The cycle count is already parsed out of every simulation into
TestResult.runtime_cycles, andrun_and_assert_testthen drops it. This surfaces it in the PyTest output and, on GitHub Actions,collects it into a table on the job summary page.
Added
Performance Summaryblock at the end of every PyTest run, listing each test's runtime in cycles.$GITHUB_STEP_SUMMARYwhen running under GitHub Actions, so the numbersare on the check page without opening the log.
Changed
run_and_assert_testprints[deeploy-perf] runtime_cycles=Nfor each simulation, before theassertions so a failing test still reports its cycles.
Notes on the implementation
Collection happens in
pytest_runtest_logreport, which fires on the xdist master for every worker'sreport. All CI jobs run
pytest -n 4, so a module-level list filled inside the tests would stay inthe worker process and never reach the summary; scraping the captured stdout on the master is what
makes the four workers' numbers land in one place.
pytest_terminal_summarydoes run in the workers as well, each holding only the tests it ran, sowriting the job summary is guarded to the master. Without that guard the shared summary file gets one
partial table per worker plus the complete one — five tables for a four-way run.
Tests on platforms that report no cycles (Generic, XDNA2) contribute no rows, and a run with no cycle
data at all prints nothing.
Verification
Real GAP9 tests through gvsoc,
-n 2:test_platforms.py::test_gap9_kernels[Kernels/FP32/Add/Regular]test_platforms.py::test_gap9_kernels[Kernels/Integer/Add/Regular]test_platforms.py::test_gap9_kernels[Kernels/Integer/MatMul/Regular]test_platforms.py::test_gap9_kernels[Kernels/Integer/Pad/Regular_1D]Also checked: serial (no
-n) gives the same table; a failing test still contributes its row; Generictests contribute none.
No workflow changes — GitHub sets
GITHUB_STEP_SUMMARYfor every step, container jobs included.PR Merge Checklist
develcommit and pointing todevel.CHANGELOG.mdfile has been updated.