diff --git a/ContextMenuProfiler.UI/Core/BenchmarkService.cs b/ContextMenuProfiler.UI/Core/BenchmarkService.cs index ac75ee2..ff792ef 100644 --- a/ContextMenuProfiler.UI/Core/BenchmarkService.cs +++ b/ContextMenuProfiler.UI/Core/BenchmarkService.cs @@ -491,7 +491,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 2eb5c6c..5532285 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"; } } }