Spaces:
Sleeping
Sleeping
# -*- coding: utf-8 -*- | |
import time | |
def get_package_version() -> str: | |
return '0.0.3' | |
class Stopwatch: | |
""" | |
Stopwatch ็ต้ๆ้ใ่จๆธฌใใใใใฎใฏใฉในใงใใ | |
Example: | |
from utils import Stopwatch | |
watch = Stopwatch.startNew() | |
# ่จๆธฌใใๅฆ็ | |
print(f"{watch.stop():.3f}") | |
""" | |
def __init__(self): | |
self._start_time = None | |
self._elapsed = 0; | |
def Elapsed(self): | |
return self._elapsed | |
def start(self) -> None: | |
self._start_time = time.perf_counter() | |
self._elapsed = 0; | |
def startNew(cls): | |
stopwatch = Stopwatch() | |
stopwatch.start() | |
return stopwatch | |
def stop(self): | |
end_time = time.perf_counter() | |
self._elapsed = end_time - self._start_time | |
return self._elapsed | |