From 01d107def3c8538f581c4bb8c8ab76660a5370cb Mon Sep 17 00:00:00 2001 From: qornwh1 Date: Tue, 3 Mar 2026 09:07:18 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=ED=8C=A8=ED=82=B7=20=EC=A0=84?= =?UTF-8?q?=EC=86=A1=EC=99=84=EB=A3=8C=20=EA=B0=9C=EC=88=98=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EC=B2=B4=ED=81=AC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EchoDummyService/DummyClientService.cs | 32 +++++++++++++++++-- .../EchoDummyService/DummyClients.cs | 13 ++++++++ ClientTester/EchoClientTester/Program.cs | 2 ++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ClientTester/EchoClientTester/EchoDummyService/DummyClientService.cs b/ClientTester/EchoClientTester/EchoDummyService/DummyClientService.cs index f35d8c1..d2c3377 100644 --- a/ClientTester/EchoClientTester/EchoDummyService/DummyClientService.cs +++ b/ClientTester/EchoClientTester/EchoDummyService/DummyClientService.cs @@ -8,6 +8,19 @@ public class DummyClientService private readonly List clients; private readonly int sendInterval; + // 유닛 테스트용 (n패킷 시간체크) + public bool IsTest + { + get; + set; + } = false; + + public int TestCount + { + get; + set; + } = 100000; + // 모든거 강종 public event Action? OnAllDisconnected; @@ -21,6 +34,16 @@ public class DummyClientService public async Task RunAsync(CancellationToken ct) { + if (IsTest) + { + foreach (DummyClients c in clients) + { + c.TestCount = TestCount; + } + + Log.Information("[TEST] 유닛 테스트 모드: 클라이언트당 {Count}개 수신 시 자동 종료", TestCount); + } + await Task.WhenAll( PollLoopAsync(ct), SendLoopAsync(ct) @@ -103,6 +126,7 @@ public class DummyClientService { int totalSent = 0, totalRecv = 0; int connected = 0; + int rttClientCount = 0; Log.Information("───────────── Performance Report ─────────────"); @@ -120,14 +144,18 @@ public class DummyClientService totalSent += c.SentCount; totalRecv += c.ReceivedCount; - totalAvgRtt += c.AvgRttMs; + if (c.RttCount > 0) + { + totalAvgRtt += c.AvgRttMs; + rttClientCount++; + } if (c.peer != null) { connected++; } } - double avgRtt = connected > 0 ? totalAvgRtt / connected : 0; + double avgRtt = rttClientCount > 0 ? totalAvgRtt / rttClientCount : 0; Log.Information("────────────────────────────────────────────"); Log.Information( diff --git a/ClientTester/EchoClientTester/EchoDummyService/DummyClients.cs b/ClientTester/EchoClientTester/EchoDummyService/DummyClients.cs index 40ee3cc..9ff2203 100644 --- a/ClientTester/EchoClientTester/EchoDummyService/DummyClients.cs +++ b/ClientTester/EchoClientTester/EchoDummyService/DummyClients.cs @@ -19,6 +19,13 @@ public class DummyClients private ConcurrentDictionary pendingPings = new(); private int seqNumber; + // 유닛 테스트용 (0 = 제한 없음) + public int TestCount + { + get; + set; + } = 0; + // 통계 public int SentCount { @@ -81,6 +88,12 @@ public class DummyClients } ReceivedCount++; + + if (TestCount > 0 && ReceivedCount >= TestCount) + { + peer.Disconnect(); + } + reader.Recycle(); }; diff --git a/ClientTester/EchoClientTester/Program.cs b/ClientTester/EchoClientTester/Program.cs index e096a27..3e3f8e2 100644 --- a/ClientTester/EchoClientTester/Program.cs +++ b/ClientTester/EchoClientTester/Program.cs @@ -35,6 +35,8 @@ class EcoClientTester await cts.CancelAsync(); }; + // service.IsTest = true; + // service.TestCount = 100; await service.RunAsync(cts.Token); service.PrintStats();