/
BespredeL
/
CVCounter
Обзор
Документация
Войти
/
BespredeL
/
CVCounter
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
Аналитика
Безопасность
master
system/core/timer.py
43 строки
1 KB
BespredeL
Introduce modular object detection (YOLO/OpenCV/ONNX) through the registry, transfer
09 июн 2026, 11:14
09 июн 2026, 11:14
d6eec0c
Код
Авторство
О чём код?
# -*- coding: utf-8 -*- # ! python3 # Developed by: Aleksandr Kireev # Created: 31.03.2025 # Updated: 31.03.2025 # Website: https://bespredel.name import time class Timer: """A class for measuring code execution time. This class implements a context manager for convenient measurement of code block execution time using the with statement. Attributes: elapsed (float): Elapsed time in seconds _start (float): Start time of measurement """ def __init__(self): """Initialize a new timer.""" self.elapsed = 0 self._start = 0 def __enter__(self): """Start time measurement. Returns: Timer: Returns the timer instance for use in with block """ self._start = time.perf_counter() return self def __exit__(self, *args): """End time measurement and save the result. Args: *args: Ignored arguments for context manager protocol compatibility """ self.elapsed = time.perf_counter() - self._start