The direct answer
Measure a local interval using two readings from the same supported monotonic clock and retain their units and attempt association. Keep UTC correlation timestamps and CPU-consumption measurements separate. A computed remaining allowance describes an observation; it does not stop remote work, prove completion or authorize another dispatch.
Choose the question before choosing the clock
A dashboard reports that an AI attempt used almost no CPU, yet the caller waited. Another record subtracts two calendar timestamps and reports a negative duration after a clock correction. These numbers answer different questions. Define whether the receipt concerns elapsed waiting, local processor consumption, or a place on an investigation timeline.
This guide proposes one narrow measurement profile: a trusted ordinary Python process records one attempt A-A, using one selected clock and integer nanosecond differences. It supplies neither a client timeout implementation nor a distributed deadline. The existing financial reservation must remain independent of this timing receipt.
Freeze the documented clock semantics
The actual Python time reference identifies version 3.15.2. It describes monotonic() as unaffected by system-clock updates and unable to go backward; its undefined reference point makes differences meaningful. monotonic_ns() returns integer nanoseconds. By contrast, time() can go backward after a system-clock change. process_time() measures current-process user and system CPU time, excluding sleep; its nanosecond variant preserves that kind of measurement.
The same reference documents get_clock_info() attributes including implementation, monotonicity, adjustability and resolution. Adjustability does not describe gradual NTP rate changes. Return units alone do not establish actual precision. These are documentation facts, not observations of an installed interpreter or host.
Our stricter application policy accepts only same-attempt, same-process, same-selected-clock readings within one nonpersistent measurement lifetime. No cross-process, restart, host migration, suspend behavior or calendar conversion is admitted by this worksheet.
Make the ordinary receipt useful
Invent a ten-millisecond local waiting allowance for a tiny teaching task. It is not a production recommendation, service-level objective, provider limit or measured latency. Before collecting anything, specify the start boundary: the local adapter has accepted A-A for its own bounded operation. The end observation is a later checkpoint in that same operation. This interval deliberately does not include any earlier user interaction or queue.
| Field | Invented value | Meaning |
|---|---|---|
| Attempt and measurement domain | A-A / P-A / clock C-A | One owned association, not a timestamp epoch |
| Start reading | 1,000,000,000 ns | First symbolic observation at the declared boundary |
| Later reading | 1,006,000,000 ns | Same clock, process and attempt |
| Elapsed difference | 6,000,000 ns = 6 ms | Later minus start |
| Original allowance | 10,000,000 ns = 10 ms | Owned local requirement |
| Remainder at observation | 4,000,000 ns = 4 ms | Allowance minus elapsed, not a future guarantee |
The positive admits this measurement receipt as internally consistent after all actual prerequisites are established. It does not admit a model call. If another observation reaches ten milliseconds, the proposed policy labels the local allowance exhausted. It retains an exceeded value honestly rather than resetting the start to make a retry appear fresh.
Preserve what the interval excludes
Define each measurement boundary in the record schema. “Adapter interval” is different from “user waited since clicking,” and either differs from provider processing time. A queue delay omitted before the start cannot be recovered by renaming the finished field end-to-end latency. A missing start or completion must remain missing, with the scope of any partial observation explicit.
Keep an independently generated UTC correlation timestamp when an investigation needs to place the receipt alongside other events. Do not reinterpret the arbitrary monotonic reading as a Unix timestamp. Record clock identity and units separately so an ordinary audit consumer cannot accidentally compare unrelated numeric fields.
Also keep local CPU accounting separate. A low CPU observation cannot excuse a long elapsed wait or establish that an upstream receiver did no work. The local duration has no authority to release an unresolved financial hold, mark an external action unsuccessful, or prove the provider stopped generating.
Review eight proposed measurement cards
| Condition | Proposed disposition |
|---|---|
| 1. Supported C-A, same P-A/A-A, complete boundaries; invented 6 ms against 10 ms | Accept only the conditional elapsed receipt and 4 ms observed remainder. |
| 2. Calendar timestamp moves backward during the interval | Do not use that subtraction for this elapsed allowance. |
| 3. Local CPU use stays small while the caller waits | Keep CPU and elapsed fields distinct; no completed-work inference. |
| 4. A reading uses seconds, another nanoseconds, or a different clock/attempt | Hold the comparison; do not invent a common reference or silently combine fields. |
| 5. Start reading survives a process restart or is moved to another host | Outside this nonpersistent profile. Do not resume its remainder by assumption. |
| 6. Valid observed elapsed value reaches or exceeds the allowance | Mark allowance exhausted at that observation; remote outcome remains separate. |
| 7. An earlier receipt had time remaining before a later proposed dispatch | It supplies no current permission or coordinated cutoff. Require the separate supported controller. |
| 8. Runtime, clock properties or the true start association is unknown | Withhold a valid measurement claim until the missing premise is established. |
The cases are paper records, not clock values collected from a machine. A rule that labels every record invalid would miss the useful positive; accepting every numeric difference would miss the association and unit failures.
Keep measurement and enforcement separate
Actual interpreter and platform support, selected clock identity, effective measurement boundaries, trusted observation capture and complete attempt association remain unimplemented and unknown here. They block a real positive. Precision and clock behavior need evidence appropriate to the deployed environment; this article supplies no nanosecond accuracy, suspension accounting or universal portability claim.
A separate controller would be needed to coordinate waiting limits, current authorization, cancellation and any later work. This worksheet implements none of those mechanisms. A timer can be late, an operation can already be in flight, and a local status cannot recall an external effect. Do not market a computed remainder as a hard execution ceiling.
For these proposed cases, no time module was imported, clock read, timer scheduled, process measured, benchmark run or client/model API called. Ordinary editorial tools are separate. Boundary remains prelaunch with planned request-path checks; its local synthetic policy evidence does not implement or validate this elapsed-time measurement profile.
Primary sources
Official references supporting the guidance. Examples in this guide are synthetic and are not reports of a production incident.