mirror of
https://github.com/2dust/v2rayN.git
synced 2025-11-18 21:52:52 +00:00
Optimize speedtest (#8325)
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
* Optimize stop-speedtest tip display * Fix speedtest termination latency
This commit is contained in:
parent
4fb41aeca1
commit
8ea5a57988
9 changed files with 75 additions and 23 deletions
11
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
11
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
|
|
@ -2355,6 +2355,15 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Press ESC to terminate the test 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string SpeedtestingPressEscToExit {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SpeedtestingPressEscToExit", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Skip test 的本地化字符串。
|
/// 查找类似 Skip test 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -2383,7 +2392,7 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Waiting for testing (press ESC to terminate)... 的本地化字符串。
|
/// 查找类似 Waiting... 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string SpeedtestingWait {
|
public static string SpeedtestingWait {
|
||||||
get {
|
get {
|
||||||
|
|
|
||||||
|
|
@ -976,7 +976,10 @@
|
||||||
<value>فعال سازی شتاب دهنده سخت افزاری (نیاز به راهاندازی مجدد)</value>
|
<value>فعال سازی شتاب دهنده سخت افزاری (نیاز به راهاندازی مجدد)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SpeedtestingWait" xml:space="preserve">
|
<data name="SpeedtestingWait" xml:space="preserve">
|
||||||
<value>در انتظار آزمایش (برای پایان دادن به ESC فشار دهید)...</value>
|
<value>در انتظار آزمایش...</value>
|
||||||
|
</data>
|
||||||
|
<data name="SpeedtestingPressEscToExit" xml:space="preserve">
|
||||||
|
<value>برای پایان دادن به ESC فشار دهید</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipDisplayLog" xml:space="preserve">
|
<data name="TipDisplayLog" xml:space="preserve">
|
||||||
<value>لطفاً در صورت قطع غیرعادی آن را خاموش کنید</value>
|
<value>لطفاً در صورت قطع غیرعادی آن را خاموش کنید</value>
|
||||||
|
|
|
||||||
|
|
@ -976,7 +976,10 @@
|
||||||
<value>Activer l’accélération matérielle (redémarrage requis)</value>
|
<value>Activer l’accélération matérielle (redémarrage requis)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SpeedtestingWait" xml:space="preserve">
|
<data name="SpeedtestingWait" xml:space="preserve">
|
||||||
<value>En attente du test (appuyer sur Échap pour arrêter)...</value>
|
<value>En attente du test...</value>
|
||||||
|
</data>
|
||||||
|
<data name="SpeedtestingPressEscToExit" xml:space="preserve">
|
||||||
|
<value>Appuyer sur Échap pour arrêter</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipDisplayLog" xml:space="preserve">
|
<data name="TipDisplayLog" xml:space="preserve">
|
||||||
<value>Désactiver cette option si coupure anormale</value>
|
<value>Désactiver cette option si coupure anormale</value>
|
||||||
|
|
|
||||||
|
|
@ -976,7 +976,10 @@
|
||||||
<value>Hardveres gyorsítás engedélyezése (újraindítást igényel)</value>
|
<value>Hardveres gyorsítás engedélyezése (újraindítást igényel)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SpeedtestingWait" xml:space="preserve">
|
<data name="SpeedtestingWait" xml:space="preserve">
|
||||||
<value>Tesztelésre vár (ESC megnyomásával megszakítható)...</value>
|
<value>Tesztelésre vár...</value>
|
||||||
|
</data>
|
||||||
|
<data name="SpeedtestingPressEscToExit" xml:space="preserve">
|
||||||
|
<value>ESC megnyomásával megszakítható</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipDisplayLog" xml:space="preserve">
|
<data name="TipDisplayLog" xml:space="preserve">
|
||||||
<value>Kérjük, kapcsolja ki rendellenes megszakadás esetén</value>
|
<value>Kérjük, kapcsolja ki rendellenes megszakadás esetén</value>
|
||||||
|
|
|
||||||
|
|
@ -976,7 +976,10 @@
|
||||||
<value>Enable hardware acceleration (requires restart)</value>
|
<value>Enable hardware acceleration (requires restart)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SpeedtestingWait" xml:space="preserve">
|
<data name="SpeedtestingWait" xml:space="preserve">
|
||||||
<value>Waiting for testing (press ESC to terminate)...</value>
|
<value>Waiting...</value>
|
||||||
|
</data>
|
||||||
|
<data name="SpeedtestingPressEscToExit" xml:space="preserve">
|
||||||
|
<value>Press ESC to terminate the test</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipDisplayLog" xml:space="preserve">
|
<data name="TipDisplayLog" xml:space="preserve">
|
||||||
<value>Please turn off when there is an abnormal disconnection</value>
|
<value>Please turn off when there is an abnormal disconnection</value>
|
||||||
|
|
|
||||||
|
|
@ -976,7 +976,10 @@
|
||||||
<value>Включить аппаратное ускорение (требуется перезагрузка)</value>
|
<value>Включить аппаратное ускорение (требуется перезагрузка)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SpeedtestingWait" xml:space="preserve">
|
<data name="SpeedtestingWait" xml:space="preserve">
|
||||||
<value>Ожидание тестирования (нажмите ESC для отмены)…</value>
|
<value>Ожидание тестирования…</value>
|
||||||
|
</data>
|
||||||
|
<data name="SpeedtestingPressEscToExit" xml:space="preserve">
|
||||||
|
<value>нажмите ESC для отмены</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipDisplayLog" xml:space="preserve">
|
<data name="TipDisplayLog" xml:space="preserve">
|
||||||
<value>Отключите при аномальном разрыве соединения</value>
|
<value>Отключите при аномальном разрыве соединения</value>
|
||||||
|
|
|
||||||
|
|
@ -976,7 +976,10 @@
|
||||||
<value>启用硬件加速 (需重启)</value>
|
<value>启用硬件加速 (需重启)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SpeedtestingWait" xml:space="preserve">
|
<data name="SpeedtestingWait" xml:space="preserve">
|
||||||
<value>等待测试中 (按 ESC 终止)...</value>
|
<value>等待测试...</value>
|
||||||
|
</data>
|
||||||
|
<data name="SpeedtestingPressEscToExit" xml:space="preserve">
|
||||||
|
<value>按 ESC 可终止测试</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipDisplayLog" xml:space="preserve">
|
<data name="TipDisplayLog" xml:space="preserve">
|
||||||
<value>当有异常断流时请关闭</value>
|
<value>当有异常断流时请关闭</value>
|
||||||
|
|
|
||||||
|
|
@ -976,7 +976,10 @@
|
||||||
<value>啟用硬體加速 (需重啟)</value>
|
<value>啟用硬體加速 (需重啟)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SpeedtestingWait" xml:space="preserve">
|
<data name="SpeedtestingWait" xml:space="preserve">
|
||||||
<value>等待測試中(按 ESC 終止)...</value>
|
<value>等待測試中...</value>
|
||||||
|
</data>
|
||||||
|
<data name="SpeedtestingPressEscToExit" xml:space="preserve">
|
||||||
|
<value>按 ECS 以終止測試</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TipDisplayLog" xml:space="preserve">
|
<data name="TipDisplayLog" xml:space="preserve">
|
||||||
<value>當有異常斷流時請關閉</value>
|
<value>當有異常斷流時請關閉</value>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
|
|
||||||
public void ExitLoop()
|
public void ExitLoop()
|
||||||
{
|
{
|
||||||
if (_lstExitLoop.Count > 0)
|
if (!_lstExitLoop.IsEmpty)
|
||||||
{
|
{
|
||||||
_ = UpdateFunc("", ResUI.SpeedtestingStop);
|
_ = UpdateFunc("", ResUI.SpeedtestingStop);
|
||||||
|
|
||||||
|
|
@ -27,6 +27,11 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool ShouldStopTest(string exitLoopKey)
|
||||||
|
{
|
||||||
|
return !_lstExitLoop.Any(p => p == exitLoopKey);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RunAsync(ESpeedActionType actionType, List<ProfileItem> selecteds)
|
private async Task RunAsync(ESpeedActionType actionType, List<ProfileItem> selecteds)
|
||||||
{
|
{
|
||||||
var exitLoopKey = Utils.GetGuid(false);
|
var exitLoopKey = Utils.GetGuid(false);
|
||||||
|
|
@ -103,6 +108,11 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lstSelected.Count > 1 && (actionType == ESpeedActionType.Speedtest || actionType == ESpeedActionType.Mixedtest))
|
||||||
|
{
|
||||||
|
NoticeManager.Instance.Enqueue(ResUI.SpeedtestingPressEscToExit);
|
||||||
|
}
|
||||||
|
|
||||||
return lstSelected;
|
return lstSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,7 +162,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
var pageSizeNext = pageSize / 2;
|
var pageSizeNext = pageSize / 2;
|
||||||
if (lstFailed.Count > 0 && pageSizeNext > 0)
|
if (lstFailed.Count > 0 && pageSizeNext > 0)
|
||||||
{
|
{
|
||||||
if (_lstExitLoop.Any(p => p == exitLoopKey) == false)
|
if (ShouldStopTest(exitLoopKey))
|
||||||
{
|
{
|
||||||
await UpdateFunc("", ResUI.SpeedtestingSkip);
|
await UpdateFunc("", ResUI.SpeedtestingSkip);
|
||||||
return;
|
return;
|
||||||
|
|
@ -190,6 +200,12 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ShouldStopTest(exitLoopKey))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
tasks.Add(Task.Run(async () =>
|
tasks.Add(Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await DoRealPing(it);
|
await DoRealPing(it);
|
||||||
|
|
@ -218,7 +234,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
List<Task> tasks = new();
|
List<Task> tasks = new();
|
||||||
foreach (var it in selecteds)
|
foreach (var it in selecteds)
|
||||||
{
|
{
|
||||||
if (_lstExitLoop.Any(p => p == exitLoopKey) == false)
|
if (ShouldStopTest(exitLoopKey))
|
||||||
{
|
{
|
||||||
await UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
|
await UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -234,13 +250,20 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
if (processService is null)
|
if (processService is null)
|
||||||
{
|
{
|
||||||
await UpdateFunc(it.IndexId, "", ResUI.FailedToRunCore);
|
await UpdateFunc(it.IndexId, "", ResUI.FailedToRunCore);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
|
|
||||||
var delay = await DoRealPing(it);
|
var delay = await DoRealPing(it);
|
||||||
if (blSpeedTest)
|
if (blSpeedTest)
|
||||||
{
|
{
|
||||||
|
if (ShouldStopTest(exitLoopKey))
|
||||||
|
{
|
||||||
|
await UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (delay > 0)
|
if (delay > 0)
|
||||||
{
|
{
|
||||||
await DoSpeedTest(downloadHandle, it);
|
await DoSpeedTest(downloadHandle, it);
|
||||||
|
|
@ -251,7 +274,6 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logging.SaveLog(_tag, ex);
|
Logging.SaveLog(_tag, ex);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue