feat : 패킷 전송완료 개수 시간 체크 기능 추가
This commit is contained in:
@@ -8,6 +8,19 @@ public class DummyClientService
|
||||
private readonly List<DummyClients> 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(
|
||||
|
||||
@@ -19,6 +19,13 @@ public class DummyClients
|
||||
private ConcurrentDictionary<int, long> 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();
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ class EcoClientTester
|
||||
await cts.CancelAsync();
|
||||
};
|
||||
|
||||
// service.IsTest = true;
|
||||
// service.TestCount = 100;
|
||||
await service.RunAsync(cts.Token);
|
||||
|
||||
service.PrintStats();
|
||||
|
||||
Reference in New Issue
Block a user