forked from mbugti/markerlessBoMI_FaMa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstopwatch.py
35 lines (26 loc) · 866 Bytes
/
stopwatch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import time
class StopWatch:
def __init__(self):
self._start_time = 0
self._elapsed_time = 0
self._pause_time = 0
self._elapsed_pause = 0
def start(self):
self._start_time = time.perf_counter_ns() * 10**-6
@property
def start_time(self):
return self._start_time
# @property
# def elapsed_time(self):
# return self._elapsed_time
@property
def elapsed_time(self):
self._elapsed_time = time.perf_counter_ns() * 10 ** -6 - self._start_time - self._elapsed_pause
return self._elapsed_time
@property
def elapsed_pause(self):
return self._elapsed_pause
def pause(self):
self._pause_time = time.perf_counter_ns() * 10 ** -6
def restart(self):
self._elapsed_pause += (time.perf_counter_ns() * 10 ** -6 - self._pause_time)