Re: Read text file to Temp file and apply formating and color chan
- From: Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Tue, 21 Aug 2007 00:05:25 -0700
Brian Cook wrote:
It takes 3Min30Sec for a 7MB file.
I am runing a P4 3.4Mhz PC with 2GB of RAM.
I assume that's "3.4Ghz", you mean. :)
Maybe you could post a concise-but-complete example of code that reliably demonstrates your scenario. I am not seeing nearly so awful a performance result.
I created a short application that simply puts 7MB worth of dummy text into a RichTextBox. Actually, it's technically 14MB...I took the conservative view that your "7MB file" is regular ASCII, and so I actually generate 7 * 1024 * 1024 characters. Since .NET uses Unicode, this is actually 14MB, not 7MB.
I generate the dummy text randomly one character at a time, one fake sentence at a time, appending each new sentence to a StringBuilder that has been preinitialized to the 7 million (or so :) ) characters. Then I use the ToString() method and assign the result to the Text property of the RichTextBox.
I ran this on my Core 2 Duo 2.33Ghz computer with 2GB of RAM.
The initialization of the data takes roughly 1 second, and roughly another 3 seconds to copy it all to the RichTextBox.
So yes, there's a fair amount of overhead in the control, relatively speaking (copying the text takes three times as long as generating it in the first place). But three and a half minutes is WAY too slow. I don't know what you're code is doing, but it seems likely to me that you have some basic algorithmic issues going on, and your problem will be better solved addressing those rather than looking for ways to make the control itself faster. My experiment suggests that the control itself has acceptable performance, when used efficiently.
IMHO, the best sample code would include something that autogenerates the data equivalent to your 7MB file, and which also includes whatever initialization code you are using, along with a RichTextBox contained by the form for the program. In other words, the program itself should be as small as possible (no downloading 7MB files :) ), but should still reproduce the same performance results you're seeing, by doing the exact same initialization you're doing.
Pete
.
- Follow-Ups:
- Re: Read text file to Temp file and apply formating and color chan
- From: Brian Cook
- Re: Read text file to Temp file and apply formating and color chan
- References:
- Re: Read text file to Temp file and apply formating and color changes
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Read text file to Temp file and apply formating and color chan
- From: Peter Duniho
- Re: Read text file to Temp file and apply formating and color chan
- From: Brian Cook
- Re: Read text file to Temp file and apply formating and color chan
- From: Peter Duniho
- Re: Read text file to Temp file and apply formating and color changes
- Prev by Date: Re: Should I instantiate the delegate or not?
- Next by Date: Re: Sharing Code
- Previous by thread: Re: Read text file to Temp file and apply formating and color chan
- Next by thread: Re: Read text file to Temp file and apply formating and color chan
- Index(es):
Relevant Pages
|
Loading