Adds check if test is valid to latency test.
This commit is contained in:
@@ -39,6 +39,10 @@ artifact_detection:
|
|||||||
enabled: true
|
enabled: true
|
||||||
threshold_db: 6.0 # Energy change threshold in dB between consecutive windows (detects level changes)
|
threshold_db: 6.0 # Energy change threshold in dB between consecutive windows (detects level changes)
|
||||||
|
|
||||||
|
latency:
|
||||||
|
max_std_dev_ms: 0.5 # Maximum allowed std deviation; test fails if exceeded
|
||||||
|
min_avg_ms: 1.0 # Minimum expected average latency; near-zero indicates bad loopback
|
||||||
|
|
||||||
latency_buildup:
|
latency_buildup:
|
||||||
measurement_interval: 10 # seconds between latency measurements
|
measurement_interval: 10 # seconds between latency measurements
|
||||||
max_duration: null # maximum test duration in seconds (null = run until canceled)
|
max_duration: null # maximum test duration in seconds (null = run until canceled)
|
||||||
|
|||||||
@@ -235,11 +235,22 @@ def run_latency_test(config: Dict, num_measurements: int = 5, save_plots: bool =
|
|||||||
last_correlation = correlation
|
last_correlation = correlation
|
||||||
last_lags = lags
|
last_lags = lags
|
||||||
|
|
||||||
|
avg = float(np.mean(latencies))
|
||||||
|
std_dev = float(np.std(latencies))
|
||||||
|
latency_cfg = config.get('latency', {})
|
||||||
|
max_std_dev_ms = latency_cfg.get('max_std_dev_ms', None)
|
||||||
|
min_avg_ms = latency_cfg.get('min_avg_ms', None)
|
||||||
|
valid = True
|
||||||
|
if max_std_dev_ms is not None and std_dev > max_std_dev_ms:
|
||||||
|
valid = False
|
||||||
|
if min_avg_ms is not None and avg < min_avg_ms:
|
||||||
|
valid = False
|
||||||
latency_stats = {
|
latency_stats = {
|
||||||
'avg': float(np.mean(latencies)),
|
'avg': avg,
|
||||||
'min': float(np.min(latencies)),
|
'min': float(np.min(latencies)),
|
||||||
'max': float(np.max(latencies)),
|
'max': float(np.max(latencies)),
|
||||||
'std': float(np.std(latencies))
|
'std': std_dev,
|
||||||
|
'valid': valid
|
||||||
}
|
}
|
||||||
|
|
||||||
if save_plots and output_dir and last_recording is not None:
|
if save_plots and output_dir and last_recording is not None:
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ def main():
|
|||||||
try:
|
try:
|
||||||
latency_stats = run_latency_test(config, num_measurements=args.measurements,
|
latency_stats = run_latency_test(config, num_measurements=args.measurements,
|
||||||
save_plots=save_plots, output_dir=test_output_dir)
|
save_plots=save_plots, output_dir=test_output_dir)
|
||||||
print(f"✓ Latency: avg={latency_stats['avg']:.3f}ms, "
|
valid = latency_stats.get('valid', True)
|
||||||
|
status = "PASS" if valid else "FAIL"
|
||||||
|
print(f"{'✓' if valid else '✗'} Latency [{status}]: avg={latency_stats['avg']:.3f}ms, "
|
||||||
f"min={latency_stats['min']:.3f}ms, max={latency_stats['max']:.3f}ms, "
|
f"min={latency_stats['min']:.3f}ms, max={latency_stats['max']:.3f}ms, "
|
||||||
f"std={latency_stats['std']:.3f}ms")
|
f"std={latency_stats['std']:.3f}ms")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user