Add benchmarking logic for memory, wer and speed (#773)

This commit is contained in:
trungkienbkhn
2024-05-04 15:12:43 +07:00
committed by GitHub
parent 847fec4492
commit 6eec07739e
7 changed files with 1973 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import argparse
import timeit
from typing import Callable
from utils import inference
parser = argparse.ArgumentParser(description="Speed benchmark")
parser.add_argument(
"--repeat",
type=int,
default=3,
help="Times an experiment will be run.",
)
args = parser.parse_args()
def measure_speed(func: Callable[[], None]):
# as written in https://docs.python.org/3/library/timeit.html#timeit.Timer.repeat,
# min should be taken rather than the average
runtimes = timeit.repeat(
func,
repeat=args.repeat,
number=10,
)
print(runtimes)
print("Min execution time: %.3fs" % (min(runtimes) / 10.0))
if __name__ == "__main__":
measure_speed(inference)