PicoVoice added + Hogwarts Legacy assistent test
This commit is contained in:
parent
0beb0ee926
commit
e456d647db
20 changed files with 274 additions and 1 deletions
27
utils/benchmark.py
Normal file
27
utils/benchmark.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import time
|
||||
|
||||
|
||||
class Benchmark:
|
||||
__marks = {} # {0: [result, point1, point2, ...]}
|
||||
|
||||
def start(self, point_name=None) -> float:
|
||||
if point_name is None:
|
||||
point_name = 0
|
||||
|
||||
self.__marks[point_name] = [0, ((time.time_ns() / 1000000) / 1000)%60, 0]
|
||||
# print(f"start: {self.__marks}")
|
||||
|
||||
return self.__marks[point_name]
|
||||
|
||||
def end(self, point_name=None) -> tuple:
|
||||
if point_name is None:
|
||||
point_name = 0
|
||||
|
||||
# print(self.__marks)
|
||||
self.__marks[point_name][2] = ((time.time_ns() / 1000000) / 1000)%60
|
||||
self.__marks[point_name][0] = self.__marks[point_name][2] - self.__marks[point_name][1]
|
||||
|
||||
return self.__marks[point_name][0], f"{int(1E3 * self.__marks[point_name][0])}ms"
|
||||
|
||||
def clear_points(self):
|
||||
self.__marks = {}
|
||||
15
utils/time.py
Normal file
15
utils/time.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import time
|
||||
|
||||
|
||||
def sleep(duration, get_now=time.perf_counter):
|
||||
"""
|
||||
Custom sleep function that works more accurate then time.sleep does.
|
||||
Taken from: https://stackoverflow.com/a/60185893/3684575
|
||||
:param duration: Duration to sleep (in seconds).
|
||||
:param get_now: Function to retrieve current time (time.perf_counter by default)
|
||||
:return:
|
||||
"""
|
||||
now = get_now()
|
||||
end = now + duration
|
||||
while now < end:
|
||||
now = get_now()
|
||||
Loading…
Add table
Add a link
Reference in a new issue