timing.py
python
sha256:37af4ab271a64f11d7bf14b4871ebaaf5dd68fb0247521007c6b034d35aa01be
Merge branch 'fix/hub-user-read-update-path' into dev
Human
9 days ago
| 1 | """Monotonic timing utility for agent-facing JSON output. |
| 2 | |
| 3 | Every ``muse`` command that emits JSON includes ``duration_ms`` and |
| 4 | ``exit_code`` so agents can measure latency and check results without |
| 5 | inspecting the process exit status separately. |
| 6 | |
| 7 | Usage:: |
| 8 | |
| 9 | elapsed = start_timer() |
| 10 | # ... do work ... |
| 11 | output["duration_ms"] = elapsed() |
| 12 | output["exit_code"] = 0 |
| 13 | """ |
| 14 | |
| 15 | import time |
| 16 | from collections.abc import Callable |
| 17 | |
| 18 | def start_timer() -> Callable[[], float]: |
| 19 | """Capture a monotonic start time and return an elapsed-ms callable. |
| 20 | |
| 21 | Returns: |
| 22 | A zero-argument callable that, when called, returns the number of |
| 23 | milliseconds elapsed since ``start_timer()`` was called, rounded |
| 24 | to three decimal places. |
| 25 | |
| 26 | Example:: |
| 27 | |
| 28 | elapsed = start_timer() |
| 29 | do_work() |
| 30 | ms = elapsed() # e.g. 12.345 |
| 31 | """ |
| 32 | t0 = time.monotonic() |
| 33 | return lambda: round((time.monotonic() - t0) * 1000, 3) |
File History
11 commits
sha256:37af4ab271a64f11d7bf14b4871ebaaf5dd68fb0247521007c6b034d35aa01be
Merge branch 'fix/hub-user-read-update-path' into dev
Human
9 days ago
sha256:b7be56ec091919a612cffe7f3c8b600209d5155517443fdac0e16954c8c7d81f
Merge 'task/git-export-ignored-file-deletion' into 'dev' — …
Human
12 days ago
sha256:8de4334a98c945aace420969d389ad678aa926d4ab4e886b2ac4c4241cb3bf2b
revert: keep pyproject.toml in canonical PEP 440 form
Sonnet 4.6
patch
15 days ago
sha256:50bb615c573aa4b928fca75b60f82ba2a659910066507cec6a95c412ae22ccb9
docs: add issue docs for push have-negotiation bug (#55) an…
Sonnet 4.6
18 days ago
sha256:d90d175cded68aae1d4ffcf4858917854195d0cd8ce1fe73cee4dbc02541cb74
chore: trigger push to surface null-OID paths
Sonnet 4.6
24 days ago
sha256:e452ad9a6ace6ccc6d875a35e06caf9da5576a970c1c36133b69a891ce5fefa8
chore: prebuild timing test
Sonnet 4.6
34 days ago
sha256:0008ab6695e3e064b3e236b24fd19e538fef6a588eb0d211622f4466d919c0b1
merge: pull staging/dev — advance to 0.2.0rc12
Sonnet 4.6
patch
36 days ago
sha256:9c33d61749fff814c5226d5386aa2af7064c2c02788594a25fdd709358132eea
fix: _PROPOSAL_PREFIX_RESOLVE_LIMIT 200 → 100 to match hub …
Sonnet 4.6
47 days ago
sha256:36c3cb3e76619d4c30a6d9bf81b5ec4ff148e30dcfed913e3114ca7b43b81c7e
fix: rename objects→blobs in push client and all stale test…
Sonnet 4.6
patch
50 days ago
sha256:c06a9b9b9fee26c68ea725b44d54b2c0a171301ce9de746d5b656617b4463a9a
fix: repair four test failures from post-migration audit
Sonnet 4.6
patch
56 days ago
sha256:1900655993c83c4107067375548a7be823e471d2515830842f1a12cba4bd3cdf
fix: unified object store migration — idempotent writes, JS…
Sonnet 4.6
minor
⚠
57 days ago