Improved and optimized speedtest

pull/6714/head
2dust 2025-02-15 11:21:35 +08:00
parent 3144f1d1c2
commit 51ac7cc8be
1 changed files with 17 additions and 6 deletions

View File

@ -58,11 +58,11 @@ namespace ServiceLib.Services
break; break;
case ESpeedActionType.Speedtest: case ESpeedActionType.Speedtest:
await RunMixedTestAsync(lstSelected, 1, exitLoopKey); await RunMixedTestAsync(lstSelected, 1, true, exitLoopKey);
break; break;
case ESpeedActionType.Mixedtest: case ESpeedActionType.Mixedtest:
await RunMixedTestAsync(lstSelected, 6, exitLoopKey); await RunMixedTestAsync(lstSelected, 6, true, exitLoopKey);
break; break;
} }
} }
@ -177,7 +177,15 @@ namespace ServiceLib.Services
} }
UpdateFunc("", string.Format(ResUI.SpeedtestingTestFailedPart, lstFailed.Count)); UpdateFunc("", string.Format(ResUI.SpeedtestingTestFailedPart, lstFailed.Count));
await RunRealPingBatchAsync(lstFailed, exitLoopKey, pageSizeNext);
if (pageSizeNext > 6)
{
await RunRealPingBatchAsync(lstFailed, exitLoopKey, pageSizeNext);
}
else
{
await RunMixedTestAsync(lstSelected, 6, false, exitLoopKey);
}
} }
} }
@ -226,7 +234,7 @@ namespace ServiceLib.Services
return true; return true;
} }
private async Task RunMixedTestAsync(List<ServerTestItem> selecteds, int concurrencyCount, string exitLoopKey) private async Task RunMixedTestAsync(List<ServerTestItem> selecteds, int concurrencyCount, bool blSpeedTest, string exitLoopKey)
{ {
using var concurrencySemaphore = new SemaphoreSlim(concurrencyCount); using var concurrencySemaphore = new SemaphoreSlim(concurrencyCount);
var downloadHandle = new DownloadService(); var downloadHandle = new DownloadService();
@ -252,9 +260,12 @@ namespace ServiceLib.Services
pid = await CoreHandler.Instance.LoadCoreConfigSpeedtest(it); pid = await CoreHandler.Instance.LoadCoreConfigSpeedtest(it);
if (pid > 0) if (pid > 0)
{ {
await Task.Delay(1000); await Task.Delay(500);
await DoRealPing(downloadHandle, it); await DoRealPing(downloadHandle, it);
await DoSpeedTest(downloadHandle, it); if (blSpeedTest)
{
await DoSpeedTest(downloadHandle, it);
}
} }
else else
{ {