Re: RichEditBox speed by sb
sb
Sun Apr 09 12:43:03 CDT 2006
Thanks for the info...very useful.
I was going to try the duel RTB approach but you saved me the time. Just
like you, I profiled my code and noticed that rtb.Select calls are the
bottleneck. I'm going to use Reflector and see if I can find a bottleneck
in the framework code that I may be able to work around...it wouldn't be the
first time that the framework code did something stupid that killed
performance. I'll let you know if I find anything of interest there.
It would be so much simpler if we could just have the underlying RichEdit
provide a callback before it paints each line to allow code to adjust the
formatting if necessary. Then I could just parse/colorize what's about to
be displayed...which would be lightning fast.
sb
"AMercer" <AMercer@discussions.microsoft.com> wrote in message
news:BF22F591-709C-4164-B8E6-A527D6171922@microsoft.com...
>> I ran one more experiment and had some success with it, but the results
>> are
>> preliminary. What I did was add a second rtb to the form that is also
>> docked
>> to all sides of the form. You will see one or the other based on z
>> order.
>> While rtb1 is in view, I write to rtb2, select, scroll, colorize, and at
>> the
>> end, bring rtb2 to the top of the z order. Double buffering with rtbs,
>> if
>> you catch my drift.
>>
>> A while back, I couldn't get anywhere by changing rtb.Visible. But
>> staying
>> visible while obscured by zorder seems to work. I get only one flash at
>> the
>> end of the updates.
>>
>> So it seems to handle flicker. How fast is it? I don't know yet. I
>> need
>> to test against some rtb contents that takes a few seconds the old way.
>> How
>> robust is it? No clue, needs development and test. But this does show
>> promise, so I thought I'd post now.
>
> I ran some more tests with large and small rtb contents, and the results
> are
> as follows. All I was doing was colorizing all occurrences of a common
> substring in the rtb text. The good news is that there was no flicker.
> The
> bad news is that there was only marginal improvement in performance.
> Under
> profiling, I found that nearly half the time was in .Select and nearly
> half
> was in property get .Text. So, even when the rtb was not actually being
> visibly scrolled, the .Select calls were expensive. I might be able to
> cache
> .Text to save speed things up, but the .Select calls can't be eliminated.
>
> The bottom line, IMO, is that the technique is effective in stopping
> flicker
> and it is not effective in improving performance. The natural way to make
> text effects in an rtb is based on selection, so it is doomed to so-so
> performance. Performance is linear with the number of .Select calls (ie
> it
> is linear with the number of highlights actually applied). I've seen some
> writeups by people promising high performance rtbs, but I haven't tried
> any
> of them.
>