mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-11 05:52:19 +02:00
Add init time and query time to setting view
This commit is contained in:
@@ -21,9 +21,6 @@ namespace Wox.Plugin.CMD
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
List<Result> results = new List<Result>();
|
||||
List<Result> pushedResults = new List<Result>();
|
||||
if (query.Search == ">")
|
||||
@@ -80,8 +77,6 @@ namespace Wox.Plugin.CMD
|
||||
catch (Exception) { }
|
||||
|
||||
}
|
||||
stopwatch.Stop();
|
||||
DebugHelper.WriteLine("CMD:" + stopwatch.ElapsedMilliseconds + "ms");
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -21,7 +22,7 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
public const string ActionKeywordWildcardSign = "*";
|
||||
private static List<PluginMetadata> pluginMetadatas;
|
||||
private static List<KeyValuePair<PluginMetadata,IInstantSearch>> instantSearches;
|
||||
private static List<KeyValuePair<PluginMetadata, IInstantSearch>> instantSearches;
|
||||
|
||||
|
||||
public static String DebuggerMode { get; private set; }
|
||||
@@ -86,15 +87,17 @@ namespace Wox.Core.Plugin
|
||||
PluginPair pair = pluginPair;
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
{
|
||||
using (new Timeit(string.Format("Init {0}", pair.Metadata.Name)))
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
pair.Plugin.Init(new PluginInitContext()
|
||||
{
|
||||
pair.Plugin.Init(new PluginInitContext()
|
||||
{
|
||||
CurrentPluginMetadata = pair.Metadata,
|
||||
Proxy = HttpProxy.Instance,
|
||||
API = API
|
||||
});
|
||||
}
|
||||
CurrentPluginMetadata = pair.Metadata,
|
||||
Proxy = HttpProxy.Instance,
|
||||
API = API
|
||||
});
|
||||
sw.Stop();
|
||||
DebugHelper.WriteLine(string.Format("Plugin init:{0} - {1}", pair.Metadata.Name, sw.ElapsedMilliseconds));
|
||||
pair.InitTime = sw.ElapsedMilliseconds;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -129,7 +132,7 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
if (string.IsNullOrEmpty(query.RawQuery)) return false;
|
||||
var strings = query.RawQuery.Split(' ');
|
||||
if(strings.Length == 1) return false;
|
||||
if (strings.Length == 1) return false;
|
||||
|
||||
var actionKeyword = strings[0].Trim();
|
||||
if (string.IsNullOrEmpty(actionKeyword)) return false;
|
||||
@@ -163,11 +166,24 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
try
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<Result> results = pair.Plugin.Query(query) ?? new List<Result>();
|
||||
results.ForEach(o =>
|
||||
{
|
||||
o.PluginID = pair.Metadata.ID;
|
||||
});
|
||||
sw.Stop();
|
||||
DebugHelper.WriteLine(string.Format("Plugin query: {0} - {1}", pair.Metadata.Name, sw.ElapsedMilliseconds));
|
||||
pair.QueryCount += 1;
|
||||
if (pair.QueryCount == 1)
|
||||
{
|
||||
pair.AvgQueryTime = sw.ElapsedMilliseconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
pair.AvgQueryTime = (pair.AvgQueryTime + sw.ElapsedMilliseconds) / 2;
|
||||
}
|
||||
API.PushResults(query, pair.Metadata, results);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
@@ -176,7 +192,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private static List<KeyValuePair<PluginMetadata,IInstantSearch>> LoadInstantSearches()
|
||||
private static List<KeyValuePair<PluginMetadata, IInstantSearch>> LoadInstantSearches()
|
||||
{
|
||||
if (instantSearches != null) return instantSearches;
|
||||
|
||||
@@ -196,7 +212,7 @@ namespace Wox.Core.Plugin
|
||||
|
||||
foreach (Type type in types)
|
||||
{
|
||||
instantSearches.Add(new KeyValuePair<PluginMetadata, IInstantSearch>(metadata,Activator.CreateInstance(type) as IInstantSearch));
|
||||
instantSearches.Add(new KeyValuePair<PluginMetadata, IInstantSearch>(metadata, Activator.CreateInstance(type) as IInstantSearch));
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
|
||||
@@ -10,6 +10,12 @@ namespace Wox.Plugin
|
||||
public IPlugin Plugin { get; set; }
|
||||
public PluginMetadata Metadata { get; set; }
|
||||
|
||||
internal long InitTime { get; set; }
|
||||
|
||||
internal long AvgQueryTime { get; set; }
|
||||
|
||||
internal int QueryCount { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Metadata.Name;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<system:String x:Key="actionKeyword">Action keyword</system:String>
|
||||
<system:String x:Key="pluginDirectory">Plugin Directory</system:String>
|
||||
<system:String x:Key="author">Author</system:String>
|
||||
<system:String x:Key="plugin_init_time">Init time: {0}ms</system:String>
|
||||
<system:String x:Key="plugin_query_time">Query time: {0}ms</system:String>
|
||||
|
||||
<!--Setting Theme-->
|
||||
<system:String x:Key="theme">Theme</system:String>
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<system:String x:Key="actionKeyword">触发关键字</system:String>
|
||||
<system:String x:Key="pluginDirectory">插件目录</system:String>
|
||||
<system:String x:Key="author">作者</system:String>
|
||||
<system:String x:Key="plugin_init_time">加载耗时:{0}ms</system:String>
|
||||
<system:String x:Key="plugin_query_time">查询耗时:{0}ms</system:String>
|
||||
|
||||
<!--设置,主题-->
|
||||
<system:String x:Key="theme">主题</system:String>
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<system:String x:Key="actionKeyword">觸發關鍵字</system:String>
|
||||
<system:String x:Key="pluginDirectory">插件目錄</system:String>
|
||||
<system:String x:Key="author">作者</system:String>
|
||||
<system:String x:Key="plugin_init_time">加載耗時:{0}ms</system:String>
|
||||
<system:String x:Key="plugin_query_time">查詢耗時:{0}ms</system:String>
|
||||
|
||||
<!--設置,主題-->
|
||||
<system:String x:Key="theme">主題</system:String>
|
||||
|
||||
@@ -95,10 +95,12 @@
|
||||
<CheckBox x:Name="cbDisablePlugin" Click="CbDisablePlugin_OnClick">
|
||||
<TextBlock Text="{DynamicResource disable}"></TextBlock>
|
||||
</CheckBox>
|
||||
<TextBlock x:Name="pluginActionKeywordTitle" Margin="50 -2 0 0">
|
||||
<TextBlock x:Name="pluginActionKeywordTitle" Margin="20 -2 0 0">
|
||||
<TextBlock Text="{DynamicResource actionKeyword}"></TextBlock>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="5 -2 0 0" ToolTip="Change Action Keyword" Cursor="Hand" MouseUp="PluginActionKeyword_OnMouseUp" Foreground="Blue" Text="key" x:Name="pluginActionKeyword"></TextBlock>
|
||||
<TextBlock Margin="20 -2 0 0" Text="Init time: 0ms" x:Name="pluginInitTime"></TextBlock>
|
||||
<TextBlock Margin="20 -2 0 0" Text="Query time: 0ms" x:Name="pluginQueryTime"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Right" Cursor="Hand" MouseUp="tbOpenPluginDirecoty_MouseUp" Foreground="Blue" Text="{DynamicResource pluginDirectory}" x:Name="tbOpenPluginDirecoty"></TextBlock>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -477,6 +477,10 @@ namespace Wox
|
||||
provider = pair.Plugin as ISettingProvider;
|
||||
pluginAuthor.Visibility = Visibility.Visible;
|
||||
pluginActionKeyword.Visibility = Visibility.Visible;
|
||||
pluginInitTime.Text =
|
||||
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
|
||||
pluginQueryTime.Text =
|
||||
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"), pair.AvgQueryTime);
|
||||
pluginActionKeywordTitle.Visibility = Visibility.Visible;
|
||||
tbOpenPluginDirecoty.Visibility = Visibility.Visible;
|
||||
pluginTitle.Text = pair.Metadata.Name;
|
||||
|
||||
Reference in New Issue
Block a user