Better name

Timeit.Stopwatch -> Stopwatch.Normal
Timeit.StopwatchDebug -> Stopwatch.Debug
This commit is contained in:
bao-qian 2015-11-04 21:49:36 +00:00
parent df0f310ddd
commit 59a4abff7c
7 changed files with 20 additions and 16 deletions

View File

@ -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)

View File

@ -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<Result> results = new List<Result>();
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; });

View File

@ -4,15 +4,15 @@ using Wox.Infrastructure.Logger;
namespace Wox.Infrastructure
{
public static class Timeit
public static class Stopwatch
{
/// <summary>
/// This stopwatch will appear only in Debug mode
/// </summary>
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);
}
/// <summary>
/// This stopwatch will also appear only in Debug mode
/// </summary>
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();

View File

@ -53,11 +53,11 @@
<Compile Include="Hotkey\KeyEvent.cs" />
<Compile Include="Logger\Log.cs" />
<Compile Include="PeHeaderReader.cs" />
<Compile Include="Stopwatch.cs" />
<Compile Include="Storage\BinaryStorage.cs" />
<Compile Include="Storage\IStorage.cs" />
<Compile Include="Storage\JsonStorage.cs" />
<Compile Include="StringMatcher.cs" />
<Compile Include="Timeit.cs" />
<Compile Include="Unidecoder.Characters.cs" />
<Compile Include="Http\HttpRequest.cs" />
<Compile Include="Storage\BaseStorage.cs" />

View File

@ -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;

View File

@ -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<string, int>(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)

View File

@ -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;
});