Compare commits
2 Commits
fix_by_cla
...
e3f365877b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3f365877b | ||
|
|
01d107def3 |
@@ -8,6 +8,19 @@ public class DummyClientService
|
|||||||
private readonly List<DummyClients> clients;
|
private readonly List<DummyClients> clients;
|
||||||
private readonly int sendInterval;
|
private readonly int sendInterval;
|
||||||
|
|
||||||
|
// 유닛 테스트용 (n패킷 시간체크)
|
||||||
|
public bool IsTest
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = false;
|
||||||
|
|
||||||
|
public int TestCount
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = 100000;
|
||||||
|
|
||||||
// 모든거 강종
|
// 모든거 강종
|
||||||
public event Action? OnAllDisconnected;
|
public event Action? OnAllDisconnected;
|
||||||
|
|
||||||
@@ -21,6 +34,16 @@ public class DummyClientService
|
|||||||
|
|
||||||
public async Task RunAsync(CancellationToken ct)
|
public async Task RunAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
if (IsTest)
|
||||||
|
{
|
||||||
|
foreach (DummyClients c in clients)
|
||||||
|
{
|
||||||
|
c.TestCount = TestCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Information("[TEST] 유닛 테스트 모드: 클라이언트당 {Count}개 수신 시 자동 종료", TestCount);
|
||||||
|
}
|
||||||
|
|
||||||
await Task.WhenAll(
|
await Task.WhenAll(
|
||||||
PollLoopAsync(ct),
|
PollLoopAsync(ct),
|
||||||
SendLoopAsync(ct)
|
SendLoopAsync(ct)
|
||||||
@@ -103,6 +126,7 @@ public class DummyClientService
|
|||||||
{
|
{
|
||||||
int totalSent = 0, totalRecv = 0;
|
int totalSent = 0, totalRecv = 0;
|
||||||
int connected = 0;
|
int connected = 0;
|
||||||
|
int rttClientCount = 0;
|
||||||
|
|
||||||
Log.Information("───────────── Performance Report ─────────────");
|
Log.Information("───────────── Performance Report ─────────────");
|
||||||
|
|
||||||
@@ -120,14 +144,18 @@ public class DummyClientService
|
|||||||
|
|
||||||
totalSent += c.SentCount;
|
totalSent += c.SentCount;
|
||||||
totalRecv += c.ReceivedCount;
|
totalRecv += c.ReceivedCount;
|
||||||
|
if (c.RttCount > 0)
|
||||||
|
{
|
||||||
totalAvgRtt += c.AvgRttMs;
|
totalAvgRtt += c.AvgRttMs;
|
||||||
|
rttClientCount++;
|
||||||
|
}
|
||||||
if (c.peer != null)
|
if (c.peer != null)
|
||||||
{
|
{
|
||||||
connected++;
|
connected++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double avgRtt = connected > 0 ? totalAvgRtt / connected : 0;
|
double avgRtt = rttClientCount > 0 ? totalAvgRtt / rttClientCount : 0;
|
||||||
|
|
||||||
Log.Information("────────────────────────────────────────────");
|
Log.Information("────────────────────────────────────────────");
|
||||||
Log.Information(
|
Log.Information(
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ public class DummyClients
|
|||||||
private int seqNumber;
|
private int seqNumber;
|
||||||
private const int MaxPendingPings = 1000;
|
private const int MaxPendingPings = 1000;
|
||||||
|
|
||||||
|
// 유닛 테스트용 (0 = 제한 없음)
|
||||||
|
public int TestCount
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = 0;
|
||||||
|
|
||||||
// 통계
|
// 통계
|
||||||
public int SentCount
|
public int SentCount
|
||||||
{
|
{
|
||||||
@@ -82,6 +89,12 @@ public class DummyClients
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReceivedCount++;
|
ReceivedCount++;
|
||||||
|
|
||||||
|
if (TestCount > 0 && ReceivedCount >= TestCount)
|
||||||
|
{
|
||||||
|
peer.Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
reader.Recycle();
|
reader.Recycle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ class EcoClientTester
|
|||||||
cts.Cancel();
|
cts.Cancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// service.IsTest = true;
|
||||||
|
// service.TestCount = 100;
|
||||||
await service.RunAsync(cts.Token);
|
await service.RunAsync(cts.Token);
|
||||||
|
|
||||||
service.PrintStats();
|
service.PrintStats();
|
||||||
|
|||||||
Reference in New Issue
Block a user