chore(legacy): Remove gui_legacy.py and refactor all tests to use gui_2.py
This commit is contained in:
@@ -8,13 +8,13 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
from api_hook_client import ApiHookClient
|
||||
|
||||
# Session-wide storage for comparing metrics across parameterized fixture runs
|
||||
# Session-wide storage for comparing metrics
|
||||
_shared_metrics = {}
|
||||
|
||||
def test_performance_benchmarking(live_gui: tuple) -> None:
|
||||
"""
|
||||
Collects performance metrics for the current GUI script (parameterized as gui.py and gui_2.py).
|
||||
"""
|
||||
Collects performance metrics for the current GUI script.
|
||||
"""
|
||||
process, gui_script = live_gui
|
||||
client = ApiHookClient()
|
||||
# Wait for app to stabilize and render some frames
|
||||
@@ -32,8 +32,6 @@ def test_performance_benchmarking(live_gui: tuple) -> None:
|
||||
fps = metrics.get('fps', 0.0)
|
||||
cpu = metrics.get('cpu_percent', 0.0)
|
||||
ft = metrics.get('last_frame_time_ms', 0.0)
|
||||
# In some CI environments without a display, metrics might be 0
|
||||
# We only record positive ones to avoid skewing averages if hooks are failing
|
||||
if fps > 0:
|
||||
fps_values.append(fps)
|
||||
cpu_values.append(cpu)
|
||||
@@ -55,23 +53,12 @@ def test_performance_benchmarking(live_gui: tuple) -> None:
|
||||
assert avg_fps >= 30, f"{gui_script} FPS {avg_fps:.2f} is below 30 FPS threshold"
|
||||
assert avg_ft <= 33.3, f"{gui_script} Frame time {avg_ft:.2f}ms is above 33.3ms threshold"
|
||||
|
||||
def test_performance_parity() -> None:
|
||||
def test_performance_baseline_check() -> None:
|
||||
"""
|
||||
Compare the metrics collected in the parameterized test_performance_benchmarking.
|
||||
"""
|
||||
if "gui_legacy.py" not in _shared_metrics or "gui_2.py" not in _shared_metrics:
|
||||
if len(_shared_metrics) < 2:
|
||||
pytest.skip("Metrics for both GUIs not yet collected.")
|
||||
gui_m = _shared_metrics["gui_legacy.py"]
|
||||
Verifies that we have performance metrics for gui_2.py.
|
||||
"""
|
||||
if "gui_2.py" not in _shared_metrics:
|
||||
pytest.skip("Metrics for gui_2.py not yet collected.")
|
||||
gui2_m = _shared_metrics["gui_2.py"]
|
||||
# FPS Parity Check (+/- 15% leeway for now, target is 5%)
|
||||
# Actually I'll use 0.15 for assertion and log the actual.
|
||||
fps_diff_pct = abs(gui_m["avg_fps"] - gui2_m["avg_fps"]) / gui_m["avg_fps"] if gui_m["avg_fps"] > 0 else 0
|
||||
cpu_diff_pct = abs(gui_m["avg_cpu"] - gui2_m["avg_cpu"]) / gui_m["avg_cpu"] if gui_m["avg_cpu"] > 0 else 0
|
||||
print("\n--- Performance Parity Results ---")
|
||||
print(f"FPS Diff: {fps_diff_pct*100:.2f}%")
|
||||
print(f"CPU Diff: {cpu_diff_pct*100:.2f}%")
|
||||
# We follow the 5% requirement for FPS
|
||||
# For CPU we might need more leeway
|
||||
assert fps_diff_pct <= 0.15, f"FPS difference {fps_diff_pct*100:.2f}% exceeds 15% threshold"
|
||||
assert cpu_diff_pct <= 3.0, f"CPU difference {cpu_diff_pct*100:.2f}% exceeds 300% threshold"
|
||||
assert gui2_m["avg_fps"] >= 30
|
||||
assert gui2_m["avg_ft"] <= 33.3
|
||||
|
||||
Reference in New Issue
Block a user