chore: reorganize timing script as benchmarks/benchmark_smtb.py - #229
Open
petercorke wants to merge 3 commits into
Open
petercorke wants to merge 3 commits into
petercorke wants to merge 3 commits into
Conversation
…oilerplate Reworks the ad hoc, partly-commented-out timing script (which had been manually re-enabled with a couple of tweaks, uncommitted, sitting in the working tree across several perf PRs this session) into something that's actually a useful reference: - Split into separate tables, one per category (SO(3)/SE(3) base functions, SE3 class, quaternion base functions, UnitQuaternion class, twist/exponential-map base functions, Twist3 class, NumPy baseline), printed with a plain header between each. Base-level (module functions on raw arrays) and class-level (constructors/ operators/properties on instances) are now consistently separated throughout, rather than mixed together - the old Twist3 section in particular had base functions (skew, trlog, trexp, rodrigues, ...) interleaved with class-level operations. - Fixed a corrupted docstring header left over from a bad find/replace on upstream (`# -*- coding", t)` / `@author", t)`), unrelated to any of this but noticed while rewriting the file. - Fixed mislabelled/ambiguous rows: `inner()` -> `np.inner(s, s).sum()`, bare `cross()` -> `base.cross(a, b)` (paired explicitly against `np.cross(a, b)`), and rows comparing decomposed-(R,t) vs full-4x4 composition that had identical labels for different code paths. - Added coverage that didn't exist before: SE3 <-> RPY, SE3 <-> Euler, SE3 -> UnitQuaternion, UnitQuaternion <-> rotation matrix, UnitQuaternion -> SE3, and SE3 @ SE3 (normalized compose) alongside SE3 * SE3. - Collapsed the `timeit.timeit(...); result(...)` two-line-per-test boilerplate into a single `timeit(stmt, label, setup)` call (module import aliased to `_timeit` to free up the name). Replaced the single `timeit.timeit(..., number=N)` run per test with `min(timeit.repeat(..., number=N, repeat=REPEATS))` - a single long run doesn't distinguish real cost from a GC pause or OS scheduling hiccup, min-of-repeats does. N dropped from 100_000 to 10_000 (an arbitrary starting point either way) since the repeats now do the work of suppressing noise that a bigger N was being used for. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The script is a dev tool, not library API; move it out of the installed package so it no longer ships in the wheel. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CPU, OS, Python, numpy and spatialmath versions and the timing settings, so a pasted table is self-describing. Modeled on RTB's rne_speed.py. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Reworks the ad hoc micro-benchmark script (
spatialmath/timing.py) into something useful as a reference. Three commits, best reviewed one at a time:SE3 @ SE3, collapsed the timeit boilerplate, and switched to min-of-5-repeats to suppress GC/scheduler noise.spatialmath/timing.pytobenchmarks/benchmark_smtb.py(pure rename). It's a dev tool, not library API, so it no longer ships in the wheel. Nothing in the repo referenced the old path.Run with
python benchmarks/benchmark_smtb.py. Checked on Python 3.14 / macOS (Apple M1).🤖 Generated with Claude Code