30 lines
711 B
Python
30 lines
711 B
Python
import pytest
|
|
import sys
|
|
import os
|
|
import time
|
|
|
|
# Ensure project root is in path
|
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
|
|
|
from performance_monitor import PerformanceMonitor
|
|
|
|
def test_perf_monitor_basic_timing():
|
|
pm = PerformanceMonitor()
|
|
pm.start_frame()
|
|
time.sleep(0.02) # 20ms
|
|
pm.end_frame()
|
|
|
|
metrics = pm.get_metrics()
|
|
assert metrics['last_frame_time_ms'] >= 20.0
|
|
pm.stop()
|
|
|
|
def test_perf_monitor_component_timing():
|
|
pm = PerformanceMonitor()
|
|
pm.start_component("test_comp")
|
|
time.sleep(0.01)
|
|
pm.end_component("test_comp")
|
|
|
|
metrics = pm.get_metrics()
|
|
assert metrics['time_test_comp_ms'] >= 10.0
|
|
pm.stop()
|