testLatency method
Measures round-trip latency to the proxy.
Implementation
Future<Duration> testLatency() async {
final sw = Stopwatch()..start();
try {
final uri = Uri.parse(_config.proxyUrl);
final req = await _client!.headUrl(uri);
final resp = await req.close();
await resp.drain<void>();
} catch (_) {
// Latency is still measured even on failure.
}
sw.stop();
return sw.elapsed;
}