(chore) moved my own solution to lec1. setup .gitignore

This commit is contained in:
vasilij_t
2026-11-28 08:48:12 +01:00
parent e09ad1f3be
commit a1b98a79ef
14 changed files with 1835 additions and 0 deletions
+13
View File
@@ -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)