forked from kosipov/pp_122-mko-lab2
(chore) moved my own solution to lec1. setup .gitignore
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import statistics
|
||||
import time
|
||||
|
||||
def bench(func, *args, repeats=5, warmup=1):
|
||||
"""Возвращает медиану, минимум и максимум времени func(*args), с."""
|
||||
for _ in range(warmup): # прогрев: кэши, JIT
|
||||
func(*args)
|
||||
times = []
|
||||
for _ in range(repeats):
|
||||
start = time.perf_counter() # монотонный таймер высокого разрешения
|
||||
func(*args)
|
||||
times.append(time.perf_counter() - start)
|
||||
return statistics.median(times), min(times), max(times)
|
||||
Reference in New Issue
Block a user