建筑分类:优雅 是默认设置

2026年9月6日2 次浏览来源:Dev.to阅读原文

正文保留英文原文(机翻易破坏代码与排版),标题/摘要已提供中文

python """ usb_tether_diag/ ├── orchestrator.py # Task queue, concurrency limiter, cancellation-safe ├── measurer.py # Raw throughput/jitter/loss engine ├── device_manager.py # USB enumeration, ADB bridge ├── config.py # Immutable test parameters ├── results.py # Immutable result objects + persistence ├── anomaly.py # The "15→106 Mbps" pattern resolver └── main.py # CLI entrypoint """ import asyncio import hashlib import time from collections import deque from dataclasses import dataclass, field from typing import Deque, Dict, Optional, List @dataclass(frozen=True) class TestConfig: test_duration_sec: float = 10.0 buffer_size_kb: int = 64 sample_interval_ms: int = 50 min_samples_per_run: int = 200 max_concurrent_tests: int = 4 per_device_buffer_cap: int = 1024 baseline_tolerance_pct: float = 0.15 outlier_sigma_threshold: float = 3.0 @dataclass(eq=True, frozen=True) class DeviceFingerprint: brand: str model: str android_version: str chipset: str _hash: str = field(compare=True, default="") python class BoundedThroughputEngine: """ Zero-leak, bounded-memory throughput measurement.

Circular buffer + Welford's online statistics.

No numpy.

No scipy.

No repeated list() conversions. """ python class USBTetherOrchestrator: def init(self, config: TestConfig): self.config = config self._device_semaphore = asyncio.Semaphore(config.max_concurrent_tests) self._results: Dict[str, List[RunResult]] = {} json { "corpus_size": 14, "measurements_per_device": 40, "total_events_sampled": "~2,240,000", "zero_cellular_data_used": true, "anomaly_resolution": { "pattern": "threshold_bypass_jump", "worst_case_baseline_mbps": 15.2, "best_case_peak_mbps": 106.8, "improvement_factor": 7.02, "winning_setting": "net.ipv4.tcp_congestion_control=bbr", "confidence": 0.94 } }

分享