mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
21 lines
496 B
Python
21 lines
496 B
Python
#!/usr/bin/env python3
|
|
|
|
import datetime
|
|
|
|
|
|
class Stopwatch:
|
|
def __init__(self):
|
|
self.reset()
|
|
|
|
@property
|
|
def duration_seconds(self) -> float:
|
|
return (datetime.datetime.utcnow() - self.start_time).total_seconds()
|
|
|
|
@property
|
|
def start_time_str(self) -> str:
|
|
return self.start_time_str_value
|
|
|
|
def reset(self) -> None:
|
|
self.start_time = datetime.datetime.utcnow()
|
|
self.start_time_str_value = self.start_time.strftime("%Y-%m-%d %H:%M:%S")
|