add lec1,lec2,lec3,lec4

This commit is contained in:
2026-11-14 10:09:26 +03:00
commit a64a74f1d5
23 changed files with 398 additions and 0 deletions
Executable
+12
View File
@@ -0,0 +1,12 @@
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)