performance increase of iso8601_ns ~49%
This commit is contained in:
parent
20f4d1ac96
commit
9007f686c2
1 changed files with 7 additions and 8 deletions
15
router.py
15
router.py
|
|
@ -277,15 +277,14 @@ async def decrement_usage(endpoint: str, model: str) -> None:
|
||||||
await publish_snapshot()
|
await publish_snapshot()
|
||||||
|
|
||||||
def iso8601_ns():
|
def iso8601_ns():
|
||||||
ns_since_epoch = time.time_ns()
|
ns = time.time_ns()
|
||||||
dt = datetime.datetime.fromtimestamp(
|
sec, ns_rem = divmod(ns, 1_000_000_000)
|
||||||
ns_since_epoch / 1_000_000_000, # seconds
|
dt = datetime.datetime.fromtimestamp(sec, tz=datetime.timezone.utc)
|
||||||
tz=datetime.timezone.utc
|
return (
|
||||||
|
f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d}T"
|
||||||
|
f"{dt.hour:02d}:{dt.minute:02d}:{dt.second:02d}."
|
||||||
|
f"{ns_rem:09d}Z"
|
||||||
)
|
)
|
||||||
iso8601_with_ns = (
|
|
||||||
dt.strftime("%Y-%m-%dT%H:%M:%S.") + f"{ns_since_epoch % 1_000_000_000:09d}Z"
|
|
||||||
)
|
|
||||||
return iso8601_with_ns
|
|
||||||
|
|
||||||
def is_base64(image_string):
|
def is_base64(image_string):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue