SaliencyMapDemo / src /utils.py
umyuu
update version
271d94c
raw
history blame
913 Bytes
# -*- 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;
@property
def Elapsed(self):
return self._elapsed
def start(self) -> None:
self._start_time = time.perf_counter()
self._elapsed = 0;
@classmethod
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