- 8 DB models (services, incidents, monitors, subscribers, etc.) - Full CRUD API for services, incidents, monitors - Public status page with live data - Incident detail page with timeline - API key authentication - Uptime monitoring scheduler - 13 tests passing - TECHNICAL_DESIGN.md with full spec
19 lines
417 B
Python
19 lines
417 B
Python
"""
|
|
Timer context manager, only used in debug.
|
|
|
|
"""
|
|
|
|
from time import time
|
|
|
|
import contextlib
|
|
from typing import Generator
|
|
|
|
|
|
@contextlib.contextmanager
|
|
def timer(subject: str = "time") -> Generator[None, None, None]:
|
|
"""print the elapsed time. (only used in debugging)"""
|
|
start = time()
|
|
yield
|
|
elapsed = time() - start
|
|
elapsed_ms = elapsed * 1000
|
|
print(f"{subject} elapsed {elapsed_ms:.1f}ms")
|