CodeOutliningRangeBased very slow, pls help!

SyntaxEditor for WPF Forum

Posted 10 years ago by cowcow
Version: 10.1.0522
Avatar
Hi,

I am testing the Range-Based Code Outlining using the sample provided under:
ProductSamples/SyntaxEditorSamples/QuickStart/CodeOutliningRangeBased/

I have created a new project to test it. The response of SyntaxEditor seems to be very slow after enabling the outlining.

Here is the testcase:
---------------------
I created a new project and add the file fillowing files to the project:

JavascriptOutliner.vb
JavascriptOutliningParser.vb
JavascriptOutliningSource.vb
JavascriptSyntaxLanguage.vb
SyntaxEditorHelper.vb

Window1.xaml
--------------
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="500" Width="600" xmlns:editor="http://schemas.actiprosoftware.com/winfx/xaml/syntaxeditor">
<Grid>
<editor:SyntaxEditor HorizontalAlignment="Stretch" Name="SyntaxEditor1" VerticalAlignment="Stretch" />
</Grid>
</Window>


Window1.xaml.vb
----------------
Public Class Window1
Public Sub New()
InitializeComponent()
SyntaxEditor1.Document.Language = New JavascriptSyntaxLanguage
End Sub
End Class


I then tried to editor a file (~50k). I found that the response of the editor was very slow after enabling outlining. I then opened the sample vb project in vs2010 and ran it. The "Code Outlining - Range-Based" sample ran much faster than the one that I had created from scratch.


I tried to put some timers in both projects to trace the response time for comparsion, here are the timers that I had put:

1) SyntaxEditor -> DocumentTextChanged

Debug.Print(String.Format("SyntaxEditor1_DocumentTextChanged TypeTime: {0}", DateTime.Now.TimeOfDay.TotalMilliseconds - OldMethodStart.TotalMilliseconds))

OldMethodStart = DateTime.Now.TimeOfDay

2) I also put one in the JavascriptOutliningParser.vb -> Function Parse

OldMethodStart = DateTime.Now.TimeOfDay

Dim out As JavascriptOutliningSource = New JavascriptOutliningSource(request.Snapshot.Document.CurrentSnapshot)

OldMethodEnd = DateTime.Now.TimeOfDay
Debug.Print(String.Format("Parse Timer: {0}", OldMethodEnd.TotalMilliseconds - OldMethodStart.TotalMilliseconds))

Return out


I ran both projects, and kept pressing a key in the Editor (trying to similar faster typing).

I got the following output from my new created project:

SyntaxEditor1_DocumentTextChanged TypeTime: 209.961000002921
Parse Timer: 146.484400004148
SyntaxEditor1_DocumentTextChanged TypeTime: 426.757800005376
Parse Timer: 178.710900001228
SyntaxEditor1_DocumentTextChanged TypeTime: 416.992200002074
Parse Timer: 142.578100003302


You can see that the SyntaxEditor triggered JavascriptOutliningParser.vb -> Parse everytime when I type a character. That means it tried to do the outlining everytime when I type.


The following output is from the Sample project. The JavascriptOutliningParser.vb -> Function Parse was trigger less frequently.


Parse Timer: 201.171800002456
SyntaxEditor1_DocumentTextChanged TypeTime: 21.4844000041485
SyntaxEditor1_DocumentTextChanged TypeTime: 20.5078000053763
SyntaxEditor1_DocumentTextChanged TypeTime: 18.5547000020742
SyntaxEditor1_DocumentTextChanged TypeTime: 19.5311999991536
SyntaxEditor1_DocumentTextChanged TypeTime: 26.3671999946237
SyntaxEditor1_DocumentTextChanged TypeTime: 21.4843000024557
SyntaxEditor1_DocumentTextChanged TypeTime: 23.4375
SyntaxEditor1_DocumentTextChanged TypeTime: 21.4844000041485
SyntaxEditor1_DocumentTextChanged TypeTime: 24.4140999987721
SyntaxEditor1_DocumentTextChanged TypeTime: 48.8281000033021
SyntaxEditor1_DocumentTextChanged TypeTime: 17.5780999958515
SyntaxEditor1_DocumentTextChanged TypeTime: 51.7577999979258
SyntaxEditor1_DocumentTextChanged TypeTime: 18.5547000020742
SyntaxEditor1_DocumentTextChanged TypeTime: 28.3202999979258
SyntaxEditor1_DocumentTextChanged TypeTime: 32.2266000062227
SyntaxEditor1_DocumentTextChanged TypeTime: 22.46099999547
SyntaxEditor1_DocumentTextChanged TypeTime: 21.4843999966979
SyntaxEditor1_DocumentTextChanged TypeTime: 43.9453000053763
SyntaxEditor1_DocumentTextChanged TypeTime: 20.5077999979258
SyntaxEditor1_DocumentTextChanged TypeTime: 22.4609000012279
SyntaxEditor1_DocumentTextChanged TypeTime: 51.7577999979258
SyntaxEditor1_DocumentTextChanged TypeTime: 23.4375
Parse Timer: 201.171899996698
SyntaxEditor1_DocumentTextChanged TypeTime: 22.4609000012279
SyntaxEditor1_DocumentTextChanged TypeTime: 30.2733999937773
SyntaxEditor1_DocumentTextChanged TypeTime: 21.4843999966979
SyntaxEditor1_DocumentTextChanged TypeTime: 21.4843999966979
SyntaxEditor1_DocumentTextChanged TypeTime: 19.5313000008464
SyntaxEditor1_DocumentTextChanged TypeTime: 20.5078000053763
SyntaxEditor1_DocumentTextChanged TypeTime: 19.5313000008464
SyntaxEditor1_DocumentTextChanged TypeTime: 23.4375
Parse Timer: 225.585899993777


I am sorry to send you such a long question, but the performance of the outlining seem to be very frustrating.

Questions
---------
1) Why the SyntaxEditor in the project that I have created triggered the outlining process for every single character I typed?

2) Can you please let me know how to set the SyntaxEditor so that the outlining can behave as the one in the sample project? (It trigger the outlining less frequetly)


Please let me know if you need my sample project.

Thanks
Cow

[Modified at 05/21/2010 07:02 AM]

Comments (2)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello,

If you look at the JavascriptSyntaxLanguage.cs code for that sample, it has this comment:

//
// NOTE: Make sure that you've set up an ambient parse request dispatcher for your application
// (see documentation on 'Parse Requests and Dispatchers') so that this parser is called in
// a worker thread as the editor is updated
//

I suspect you didn't start the ambient parse request dispatcher in your app startup. Therefore all the code that would normally run in a worker thread is being run in the main UI thread and thus blocking your UI.


Actipro Software Support

Posted 10 years ago by cowcow
Avatar
Yes, I didn't start the ambient parse request dispatcher in app startup

Thanks.
The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.