472,145 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

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 2497
"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
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.