469,296 Members | 2,074 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,296 developers. It's quick & easy.

Performance issues with XMLTextReader

Hi there,

I need to parse a lot of html-files from wikipedia, and I need to do it
as fast as possible. So I started a little testing with XMLTextReader,
but the results I get confuse me. It seems that the Reader ALWAYS needs
about 1 second for the first textReader.Read()

Here's my testcode:

XmlTextReader _myReader = new XmlTextReader(textBox1.Text);
DateTime _firstRead = DateTime.MinValue;

DateTime _start = DateTime.Now;
_myReader.Read();
_firstRead = DateTime.Now;

while (_myReader.Read())
{
}

MessageBox.Show("FirstRead: " + Convert.ToString(_firstRead - _start) +
". Overall: " + Convert.ToString(DateTime.Now - _start));

And here are the results for a 134kb file:
FirstRead: 0.9218750. Overall: 0.9375

I get a similar result for a 15kb file. (And btw. the same result when
using DOM)

Any ideas why it takes so long for the first read and what to do about it?

I have downloaded the whole wikipedia and extract it to the filesystem.
Is that the reason?

Ciao,
Frank
Mar 8 '07 #1
2 2383
"Frank Schumacher" <f_********@informatik.uni-leipzig.dewrote in message
news:uo**************@TK2MSFTNGP02.phx.gbl...
Hi there,

I need to parse a lot of html-files from wikipedia, and I need to do it as
fast as possible. So I started a little testing with XMLTextReader, but
the results I get confuse me. It seems that the Reader ALWAYS needs about
1 second for the first textReader.Read()

Here's my testcode:

XmlTextReader _myReader = new XmlTextReader(textBox1.Text);
DateTime _firstRead = DateTime.MinValue;

DateTime _start = DateTime.Now;
_myReader.Read();
_firstRead = DateTime.Now;

while (_myReader.Read())
{
}

MessageBox.Show("FirstRead: " + Convert.ToString(_firstRead - _start) + ".
Overall: " + Convert.ToString(DateTime.Now - _start));

And here are the results for a 134kb file:
FirstRead: 0.9218750. Overall: 0.9375

I get a similar result for a 15kb file. (And btw. the same result when
using DOM)

Any ideas why it takes so long for the first read and what to do about it?

I have downloaded the whole wikipedia and extract it to the filesystem. Is
that the reason?
Which version of .NET are you running?

John
Mar 8 '07 #2
Hi John,
Which version of .NET are you running?
I'm working with Visual Studi 2005, so it is .NET 2.0, I guess.

Ciao,
Frank
Mar 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by Brian Patterson | last post: by
5 posts views Thread by sandy | last post: by
4 posts views Thread by Tomas Rivas | last post: by
115 posts views Thread by Mark Shelor | last post: by
9 posts views Thread by oafyuf | last post: by
1 post views Thread by George Durzi | last post: by
2 posts views Thread by Mark | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.