Download src/utils/timing.py from danishk84/NovaGuide: direct link, hf CLI and curl.
- Browser
- Download file 524 Bytes
-
https://huggingface.co/spaces/danishk84/NovaGuide/resolve/main/src/utils/timing.py
- Command line
-
hf download hf://spaces/danishk84/NovaGuide/src/utils/timing.py
-
curl -L -o timing.py https://huggingface.co/spaces/danishk84/NovaGuide/resolve/main/src/utils/timing.py
524 Bytes
| """UTC timestamp and elapsed-time helpers.""" | |
| from datetime import datetime, timezone | |
| from time import time_ns | |
| def current_utc_iso() -> str: | |
| """Return a timezone-aware UTC timestamp in ISO 8601 format.""" | |
| return datetime.now(timezone.utc).isoformat() | |
| def now_ms() -> int: | |
| """Return Unix time in integer milliseconds.""" | |
| return time_ns() // 1_000_000 | |
| def elapsed_ms(start_ms: int) -> int: | |
| """Return non-negative elapsed milliseconds since ``start_ms``.""" | |
| return max(0, now_ms() - start_ms) | |