Files
douyin_guaji-main/douyin/logging/action_tracker.py
T
Your Name a0aad21835 feat: Optimize ADB exec-out and OCR performance
- Introduced performance enhancements for ADB exec-out, reducing execution time by 10-20% through the use of Popen with streaming reads, increased buffer sizes, and removal of unnecessary fsync calls.
- Implemented optimizations in OCR processing, cutting recognition time by 50% by refining button recognition logic and improving image loading and preprocessing methods.
- Added detailed performance diagnostics and configuration options to facilitate further optimizations.
- Created new documentation files outlining the performance improvements and recommendations for future enhancements.
2026-01-02 02:06:01 +08:00

66 lines
927 B
Python

"""操作追踪装饰器:自动记录函数耗时与操作信息"""
from __future__ import annotations
import time
from functools import wraps
from .performance_tracker import PerformanceTracker
from .action_logger import ActionLogger
_perf = PerformanceTracker()
_logger = ActionLogger()
def track_action(name: str = ""):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
timer = _perf.start_timer(name or func.__name__)
t0 = time.time()
try:
result = func(*args, **kwargs)
return result
finally:
elapsed = _perf.end_timer(timer)
elapsed = elapsed if elapsed is not None else time.time() - t0
_logger.log_step(name or func.__name__, elapsed=elapsed)
return wrapper
return decorator
__all__ = ["track_action"]