From 390463b41748c324cd3afbf6310dcce4ac5c68b0 Mon Sep 17 00:00:00 2001 From: ZYJ <2897680945@qq.com> Date: Sun, 15 Mar 2026 22:35:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E4=BF=AE=E5=A4=8D=E2=80=9C=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E5=8A=A0=E8=BD=BD/=E8=8F=9C=E5=8D=95=E6=80=BB?= =?UTF-8?q?=E8=80=97=E6=97=B6=E2=80=9D=E9=95=BF=E6=9C=9F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=200ms=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/BenchmarkService.cs | 2 +- .../ViewModels/DashboardViewModel.cs | 32 ++++++------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/ContextMenuProfiler.UI/Core/BenchmarkService.cs b/ContextMenuProfiler.UI/Core/BenchmarkService.cs index a0f5c0a..bb29a3f 100644 --- a/ContextMenuProfiler.UI/Core/BenchmarkService.cs +++ b/ContextMenuProfiler.UI/Core/BenchmarkService.cs @@ -480,7 +480,7 @@ public List RunBenchmark(string targetPath) return RunSystemBenchmark(ScanMode.Targeted); // Simplified for now } - public long RunRealShellBenchmark(string? filePath = null) => 0; + public long RunRealShellBenchmark(string? filePath = null) => -1; private string DetermineCategory(IEnumerable locations) { diff --git a/ContextMenuProfiler.UI/ViewModels/DashboardViewModel.cs b/ContextMenuProfiler.UI/ViewModels/DashboardViewModel.cs index 578c914..ae51e1f 100644 --- a/ContextMenuProfiler.UI/ViewModels/DashboardViewModel.cs +++ b/ContextMenuProfiler.UI/ViewModels/DashboardViewModel.cs @@ -326,6 +326,7 @@ private async Task ScanSystem() _lastScanMode = "System"; StatusText = LocalizationService.Instance["Dashboard.Status.ScanningSystem"]; IsBusy = true; + RealLoadTime = LocalizationService.Instance["Dashboard.RealLoad.Measuring"]; App.Current.Dispatcher.Invoke(() => { @@ -375,6 +376,9 @@ void TryCompleteUiDrain() TryCompleteUiDrain(); await uiDrainTcs.Task; + // Ensure summary values are refreshed even if no progress callback was emitted. + UpdateStats(); + StatusText = string.Format(LocalizationService.Instance["Dashboard.Status.ScanComplete"], Results.Count); NotificationService.Instance.ShowSuccess(LocalizationService.Instance["Dashboard.Notify.ScanComplete.Title"], string.Format(LocalizationService.Instance["Dashboard.Notify.ScanComplete.Message"], Results.Count)); } @@ -477,8 +481,6 @@ private async Task ScanFile(string filePath) NotificationService.Instance.ShowSuccess(LocalizationService.Instance["Dashboard.Notify.ScanComplete.Title"], string.Format(LocalizationService.Instance["Dashboard.Notify.ScanCompleteForFile.Message"], results.Count, System.IO.Path.GetFileName(filePath))); } - // Run Real-World Benchmark (Parallel but after discovery to avoid COM conflicts if any) - await RunRealBenchmark(filePath); } catch (Exception ex) { @@ -493,26 +495,6 @@ private async Task ScanFile(string filePath) } } - private async Task RunRealBenchmark(string? filePath = null) - { - try - { - long elapsed = await Task.Run(() => _benchmarkService.RunRealShellBenchmark(filePath)); - if (elapsed >= 0) - { - RealLoadTime = $"{elapsed} ms"; - } - else - { - RealLoadTime = LocalizationService.Instance["Dashboard.RealLoad.Failed"]; - } - } - catch - { - RealLoadTime = LocalizationService.Instance["Dashboard.RealLoad.Error"]; - } - } - private void ApplyLocalizedCategoryNames() { Categories = new ObservableCollection @@ -721,6 +703,12 @@ private void UpdateStats() TotalLoadTime = totalTime; ActiveLoadTime = activeTime; DisabledLoadTime = disabledTime; + + // "Real load" uses wall-clock IPC time when available; fall back to measured COM stage total. + long realLoadMs = Results + .Where(r => r.IsEnabled) + .Sum(r => r.WallClockTime > 0 ? r.WallClockTime : Math.Max(0, r.TotalTime)); + RealLoadTime = realLoadMs > 0 ? $"{realLoadMs} ms" : "N/A"; } } }