diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 45b31e0a13..7f98198644 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -8,6 +8,7 @@ using System.Windows; using IWshRuntimeLibrary; using Wox.Infrastructure; using Wox.Plugin.Program.ProgramSources; +using Stopwatch = Wox.Infrastructure.Stopwatch; namespace Wox.Plugin.Program { @@ -70,12 +71,12 @@ namespace Wox.Plugin.Program { this.context = context; this.context.API.ResultItemDropEvent += API_ResultItemDropEvent; - Timeit.StopwatchDebug("Preload programs", () => + Stopwatch.Debug("Preload programs", () => { programs = ProgramCacheStorage.Instance.Programs; }); Debug.WriteLine($"Preload {programs.Count} programs from cache"); - Timeit.StopwatchDebug("Program Index", IndexPrograms); + Stopwatch.Debug("Program Index", IndexPrograms); } void API_ResultItemDropEvent(Result result, IDataObject dropObject, DragEventArgs e) diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index 5413d24657..aba4299a5d 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -13,6 +13,7 @@ using Wox.Core.UserSettings; using Wox.Infrastructure; using Wox.Infrastructure.Logger; using Wox.Plugin; +using Stopwatch = Wox.Infrastructure.Stopwatch; namespace Wox.Core.Plugin { @@ -92,7 +93,7 @@ namespace Wox.Core.Plugin PluginPair pair = pluginPair; ThreadPool.QueueUserWorkItem(o => { - var milliseconds = Timeit.Stopwatch($"Plugin init: {pair.Metadata.Name}", () => + var milliseconds = Stopwatch.Normal($"Plugin init: {pair.Metadata.Name}", () => { pair.Plugin.Init(new PluginInitContext { @@ -160,7 +161,7 @@ namespace Wox.Core.Plugin if (customizedPluginConfig != null && customizedPluginConfig.Disabled) continue; if (IsInstantQueryPlugin(plugin)) { - Timeit.StopwatchDebug($"Instant Query for {plugin.Metadata.Name}", () => + Stopwatch.Debug($"Instant Query for {plugin.Metadata.Name}", () => { QueryForPlugin(plugin, query); }); @@ -180,7 +181,7 @@ namespace Wox.Core.Plugin try { List results = new List(); - var milliseconds = Timeit.Stopwatch($"Query for {pair.Metadata.Name}", () => + var milliseconds = Stopwatch.Normal($"Query for {pair.Metadata.Name}", () => { results = pair.Plugin.Query(query) ?? results; results.ForEach(o => { o.PluginID = pair.Metadata.ID; }); diff --git a/Wox.Infrastructure/Timeit.cs b/Wox.Infrastructure/Stopwatch.cs similarity index 73% rename from Wox.Infrastructure/Timeit.cs rename to Wox.Infrastructure/Stopwatch.cs index 425821ecc8..c0d8288540 100644 --- a/Wox.Infrastructure/Timeit.cs +++ b/Wox.Infrastructure/Stopwatch.cs @@ -4,15 +4,15 @@ using Wox.Infrastructure.Logger; namespace Wox.Infrastructure { - public static class Timeit + public static class Stopwatch { /// /// This stopwatch will appear only in Debug mode /// - public static void StopwatchDebug(string name, Action action) + public static void Debug(string name, Action action) { #if DEBUG - Stopwatch(name, action); + Normal(name, action); #else action(); #endif @@ -22,16 +22,16 @@ namespace Wox.Infrastructure private static void WriteTimeInfo(string name, long milliseconds) { string info = $"{name} : {milliseconds}ms"; - Debug.WriteLine(info); + System.Diagnostics.Debug.WriteLine(info); Log.Info(info); } /// /// This stopwatch will also appear only in Debug mode /// - public static long Stopwatch(string name, Action action) + public static long Normal(string name, Action action) { - var stopWatch = new Stopwatch(); + var stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); action(); stopWatch.Stop(); diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index a5ef083e79..e3740ee2cc 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -53,11 +53,11 @@ + - diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index ae75a53101..3c6ea28abd 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -29,7 +29,7 @@ namespace Wox protected override void OnStartup(StartupEventArgs e) { - Timeit.StopwatchDebug("Startup Time", () => + Stopwatch.Debug("Startup Time", () => { base.OnStartup(e); DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; diff --git a/Wox/ImageLoader/ImageLoader.cs b/Wox/ImageLoader/ImageLoader.cs index daf83cabe1..63b30514e2 100644 --- a/Wox/ImageLoader/ImageLoader.cs +++ b/Wox/ImageLoader/ImageLoader.cs @@ -8,6 +8,7 @@ using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; using Wox.Infrastructure; +using Stopwatch = Wox.Infrastructure.Stopwatch; namespace Wox.ImageLoader { @@ -57,7 +58,7 @@ namespace Wox.ImageLoader { //ImageCacheStroage.Instance.TopUsedImages can be changed during foreach, so we need to make a copy var imageList = new Dictionary(ImageCacheStroage.Instance.TopUsedImages); - Timeit.StopwatchDebug($"Preload {imageList.Count} images", () => + Stopwatch.Debug($"Preload {imageList.Count} images", () => { foreach (var image in imageList) { @@ -82,7 +83,7 @@ namespace Wox.ImageLoader { if (string.IsNullOrEmpty(path)) return null; ImageSource img = null; - Timeit.StopwatchDebug($"Loading image path: {path}", () => + Stopwatch.Debug($"Loading image path: {path}", () => { if (addToCache) diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 60b3d10a4c..e8f316a574 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -20,6 +20,7 @@ using Wox.Helper; using Wox.Infrastructure; using Wox.Plugin; using Application = System.Windows.Forms.Application; +using Stopwatch = Wox.Infrastructure.Stopwatch; namespace Wox { @@ -329,7 +330,7 @@ namespace Wox private void OnThemeTabSelected() { - Timeit.StopwatchDebug("theme load", () => + Stopwatch.Debug("theme load", () => { var s = Fonts.SystemFontFamilies; });