We have found issue in IntelliPromptCompletion performance when we have 2000 item in Intellisense.
This is the source code and we measure the performance when we open the intellisense in Syntax Editor.
private void ShowCompletionList(bool allowAutoComplete)
{
// Ensure the editor has focus
editor.Focus();
var session = this.CreateCompletionSession();
session.CanCommitWithoutPopup = allowAutoComplete;
// Open the session
session.Open(editor.ActiveView);
}
private CompletionSession CreateCompletionSession()
{
// Create a session
var session = new CompletionSession();
session.CanFilterUnmatchedItems = filterUnmatchedItemsCheckBox.IsChecked.Value;
session.MatchOptions = CompletionMatchOptions.UseAcronyms | CompletionMatchOptions.UseShorthand;
// Add some items
session.Items.Add(new CompletionItem("_intValue", new CommonImageSourceProvider(CommonImage.FieldPrivate),
new HtmlContentProvider("<span style=\"color: #0000ff;\">int</span> <b>Foo._intValue</b><br/><span style=\"color: #008000;\">An integer value.</span>")));
//// add more ....
for (int i = 0; i < 2000; i++)
{
var addText = string.Format("Add more Item[{0}]", i);
session.Items.Add(new CompletionItem(addText, new CommonImageSourceProvider(CommonImage.FieldPrivate),
new HtmlContentProvider("<span style=\"color: #0000ff;\">int</span> <b>Foo._intValue</b><br/><span style=\"color: #008000;\">An integer value.</span>")));
}
session.Items.Add(new CompletionItem("Equals", new CommonImageSourceProvider(CommonImage.MethodPublic),
new HtmlContentProvider("<span style=\"color: #0000ff;\">bool</span> <b>object.Equals</b>(<span style=\"color: #0000ff;\">object</span> obj)<br/><span style=\"color: #008000;\">Determines whether the specified <b>System.Object</b> is equal to the current <b>System.Object</b>.</span>")));
session.Items.Add(new CompletionItem("GetHashCode", new CommonImageSourceProvider(CommonImage.MethodPublic),
new HtmlContentProvider("<span style=\"color: #0000ff;\">int</span> <b>object.GetHashCode</b>()<br/><span style=\"color: #008000;\">Gets a hash code for this <b>System.Object</b>.</span>")));
session.Items.Add(new CompletionItem("GetType", new CommonImageSourceProvider(CommonImage.MethodPublic),
new HtmlContentProvider("<span style=\"color: #008080;\">Type</span> <b>object.GetType</b>()<br/><span style=\"color: #008000;\">Gets the <b>System.Type</b> of the current instance.</span>")));
session.Items.Add(new CompletionItem("IntValue", new CommonImageSourceProvider(CommonImage.PropertyPublic),
new HtmlContentProvider("<span style=\"color: #0000ff;\">int</span> <b>Foo.IntValue</b><br/><span style=\"color: #008000;\">An integer value.</span>")));
session.Items.Add(new CompletionItem("IntValueChanged", new CommonImageSourceProvider(CommonImage.EventPublic),
new HtmlContentProvider("<span style=\"color: #008080;\">EventHandler</span> <b>Foo.IntValueChanged</b>")));
session.Items.Add(new CompletionItem("OnIntValueChanged", new CommonImageSourceProvider(CommonImage.MethodProtected),
new HtmlContentProvider("<span style=\"color: #0000ff;\">void</span> <b>Foo.OnIntValueChanged</b>(<span style=\"color: #008080;\">EventArgs</span> e)")));
session.Items.Add(new CompletionItem("ToString", new CommonImageSourceProvider(CommonImage.MethodPublic),
new HtmlContentProvider("<span style=\"color: #0000ff;\">string</span> <b>object.ToString</b>()<br/><span style=\"color: #008000;\">Returns the string representation of the object.</span>")));
It tooks 2s to open the intellisense in ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.CompletionSession.Open(IEditorView).
This is the performance measure result.
29.69% Open • 2,072 ms • 1 call • ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.CompletionSession.Open(IEditorView)
29.66% Open • 2,070 ms • 1 call • ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.IntelliPromptSessionBase.Open(IEditorView, TextRange)
29.51% OnOpened • 2,059 ms • 1 call • ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.CompletionSession.OnOpened(EventArgs)
28.42% SetValue • 1,983 ms • 5 calls • System.Windows.DependencyObject.SetValue(DependencyProperty, Object)
21.91% OnApplyTemplate • 1,529 ms • 1 call • ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionList.OnApplyTemplate
21.77% #Jlc • 1,519 ms • 1 call • ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionList.#Jlc
13.81% Measure • 963 ms • 2,002 calls • System.Windows.UIElement.Measure(Size)
12.86% MeasureOverride • 897 ms • 2,002 calls • ActiproSoftware.Windows.Controls.PixelSnapper.MeasureOverride(Size)
12.81% Measure • 894 ms • 2,002 calls • System.Windows.UIElement.Measure(Size)
10.20% MeasureOverride • 711 ms • 2,002 calls • ActiproSoftware.Windows.Controls.PixelSnapper.MeasureOverride(Size)
10.12% Measure • 706 ms • 2,002 calls • System.Windows.UIElement.Measure(Size)
9.81% MeasureOverride • 684 ms • 2,002 calls • ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionItemText.MeasureOverride(Size)
►9.72% #Hub • 678 ms • 2,002 calls • ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionItemText.#Hub(DrawingContext)
It spents most time to measure the text width and height in ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionItemText.#Hub(DrawingContext).
If we can improve the measure logic using better logic or fixed value, it will be 2 times faster than original.
We have Syntax Editor source code. So we changed the code and measured the performance.
[Modified 12 years ago]