mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
update pretty printing of time
This commit is contained in:
1 parent
7d8beaaed4
commit
6b9506a779
1 file changed
+18
-8
@@ -3,7 +3,6 @@ Generic Writer class
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
import enum
|
import enum
|
||||||
import os
|
import os
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
@@ -268,13 +267,24 @@ def _cursorup(x: int):
|
|||||||
print(f"\r\033[{x}A", end="\x1b[1K\r")
|
print(f"\r\033[{x}A", end="\x1b[1K\r")
|
||||||
|
|
||||||
|
|
||||||
def _format_time(v):
|
def _format_time(seconds):
|
||||||
if v < 1.0:
|
"""utility tool to format time in human readable form given seconds"""
|
||||||
ms = v * 1e3
|
ms = seconds % 1
|
||||||
v = f"{ms:0.4f} ms"
|
ms = ms * 1e3
|
||||||
else:
|
seconds = int(seconds)
|
||||||
v = str(datetime.timedelta(seconds=v))
|
days, seconds = divmod(seconds, 86400)
|
||||||
return v
|
hours, seconds = divmod(seconds, 3600)
|
||||||
|
minutes, seconds = divmod(seconds, 60)
|
||||||
|
if days > 0:
|
||||||
|
return f"{days} d, {hours} h, {minutes} m, {seconds} s"
|
||||||
|
if hours > 0:
|
||||||
|
return f"{hours} h, {minutes} m, {seconds} s"
|
||||||
|
if minutes > 0:
|
||||||
|
return f"{minutes} m, {seconds} s"
|
||||||
|
if seconds > 0:
|
||||||
|
return f"{seconds} s, {ms:0.3f} ms"
|
||||||
|
|
||||||
|
return f"{ms:0.3f} ms"
|
||||||
|
|
||||||
|
|
||||||
@decorate_all([check_main_thread])
|
@decorate_all([check_main_thread])
|
||||||
|
|||||||
Reference in new issue
Block a user