fastest way to ReadXmlSchema, ReadXml and WriteXml

D

DraguVaso

Hi,

I should use XML to synchronize the data from different (VB.NET)
applications, and I was just wondering which Overloads of these functions
( ReadXmlSchema, ReadXml and WriteXml) goes the fastest? I don't think the
ReadXMLSchema would give a lot of difference, but maybe the overlaods of
ReadXml and WriteXml will. Especially with larges files/datatables...

Should I use the IO.Stream? The XmlReader/XmlWriter?

Any help would be really appreciated!

Thanks a lot in advance,

Pieter


The overloads:

Reads the XML schema from the specified Stream into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(Stream)
Reads the XML schema from the specified file into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(String)
Reads the XML schema from the specified TextReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(TextReader)
Reads the XML schema from the specified XmlReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(XmlReader)

Reads XML schema and data into the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Function ReadXml(Stream) As XmlReadMode
Reads XML schema and data into the DataSet using the specified file.
[Visual Basic] Overloads Public Function ReadXml(String) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader.
[Visual Basic] Overloads Public Function ReadXml(TextReader) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader.
[Visual Basic] Overloads Public Function ReadXml(XmlReader) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.Stream and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(Stream, XmlReadMode) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified file and
XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(String, XmlReadMode) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(TextReader, XmlReadMode) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(XmlReader, XmlReadMode) As
XmlReadMode


Writes the current data for the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Sub WriteXml(Stream)
Writes the current data for the DataSet to the specified file.
[Visual Basic] Overloads Public Sub WriteXml(String)
Writes the current data for the DataSet using the specified TextWriter.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter)
Writes the current data for the DataSet to the specified XmlWriter.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter)
Writes the current data, and optionally the schema, for the DataSet using
the specified System.IO.Stream and XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(Stream, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet to the
specified file using the specified XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(String, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified TextWriter and XmlWriteMode. To write the schema, set the
value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified XmlWriter and XmlWriteMode. To write the schema, set the value
for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter, XmlWriteMode)
 
S

Stephany Young

The easiest way to find out is try them.


DraguVaso said:
Hi,

I should use XML to synchronize the data from different (VB.NET)
applications, and I was just wondering which Overloads of these functions
( ReadXmlSchema, ReadXml and WriteXml) goes the fastest? I don't think the
ReadXMLSchema would give a lot of difference, but maybe the overlaods of
ReadXml and WriteXml will. Especially with larges files/datatables...

Should I use the IO.Stream? The XmlReader/XmlWriter?

Any help would be really appreciated!

Thanks a lot in advance,

Pieter


The overloads:

Reads the XML schema from the specified Stream into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(Stream)
Reads the XML schema from the specified file into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(String)
Reads the XML schema from the specified TextReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(TextReader)
Reads the XML schema from the specified XmlReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(XmlReader)

Reads XML schema and data into the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Function ReadXml(Stream) As XmlReadMode
Reads XML schema and data into the DataSet using the specified file.
[Visual Basic] Overloads Public Function ReadXml(String) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader.
[Visual Basic] Overloads Public Function ReadXml(TextReader) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader.
[Visual Basic] Overloads Public Function ReadXml(XmlReader) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.Stream and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(Stream, XmlReadMode) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified file and
XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(String, XmlReadMode) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(TextReader, XmlReadMode)
As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(XmlReader, XmlReadMode)
As
XmlReadMode


Writes the current data for the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Sub WriteXml(Stream)
Writes the current data for the DataSet to the specified file.
[Visual Basic] Overloads Public Sub WriteXml(String)
Writes the current data for the DataSet using the specified TextWriter.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter)
Writes the current data for the DataSet to the specified XmlWriter.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter)
Writes the current data, and optionally the schema, for the DataSet using
the specified System.IO.Stream and XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(Stream, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet to the
specified file using the specified XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(String, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified TextWriter and XmlWriteMode. To write the schema, set the
value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified XmlWriter and XmlWriteMode. To write the schema, set the
value
for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter, XmlWriteMode)
 
D

DraguVaso

Thanks, you didn't sleep too well thisn ight I guess? ;-)

It would jsut be nice if anybody couldgive me tha right answer :) I think
the "Overloads Public Function ReadXml(XmlReader, XmlReadMode) As
XmlReadMode" is the fastets, ot maybe the one without the XmlReadMode, and
using a XmlTextReader.
But there are different ways to open the XmlTextReader, and different ways
for the xmlReadMode, etc...

So this makes the total to hundreds of ways to do it. so testing one after
another would take to much time. I just hink there mya be a 'right' solution
out there...

Pieter


Stephany Young said:
The easiest way to find out is try them.


DraguVaso said:
Hi,

I should use XML to synchronize the data from different (VB.NET)
applications, and I was just wondering which Overloads of these functions
( ReadXmlSchema, ReadXml and WriteXml) goes the fastest? I don't think the
ReadXMLSchema would give a lot of difference, but maybe the overlaods of
ReadXml and WriteXml will. Especially with larges files/datatables...

Should I use the IO.Stream? The XmlReader/XmlWriter?

Any help would be really appreciated!

Thanks a lot in advance,

Pieter


The overloads:

Reads the XML schema from the specified Stream into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(Stream)
Reads the XML schema from the specified file into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(String)
Reads the XML schema from the specified TextReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(TextReader)
Reads the XML schema from the specified XmlReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(XmlReader)

Reads XML schema and data into the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Function ReadXml(Stream) As XmlReadMode
Reads XML schema and data into the DataSet using the specified file.
[Visual Basic] Overloads Public Function ReadXml(String) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader.
[Visual Basic] Overloads Public Function ReadXml(TextReader) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader.
[Visual Basic] Overloads Public Function ReadXml(XmlReader) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.Stream and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(Stream, XmlReadMode) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified file and
XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(String, XmlReadMode) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(TextReader, XmlReadMode)
As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(XmlReader, XmlReadMode)
As
XmlReadMode


Writes the current data for the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Sub WriteXml(Stream)
Writes the current data for the DataSet to the specified file.
[Visual Basic] Overloads Public Sub WriteXml(String)
Writes the current data for the DataSet using the specified TextWriter.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter)
Writes the current data for the DataSet to the specified XmlWriter.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter)
Writes the current data, and optionally the schema, for the DataSet using
the specified System.IO.Stream and XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(Stream, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet to the
specified file using the specified XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(String, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified TextWriter and XmlWriteMode. To write the schema, set the
value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified XmlWriter and XmlWriteMode. To write the schema, set the
value
for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter, XmlWriteMode)
 
S

Stephany Young

So you expect others to try it out for you and report back?

If you are too lazy to try write a few lines of code and try it for
yourself, then you aren't going to learn much.


DraguVaso said:
Thanks, you didn't sleep too well thisn ight I guess? ;-)

It would jsut be nice if anybody couldgive me tha right answer :) I think
the "Overloads Public Function ReadXml(XmlReader, XmlReadMode) As
XmlReadMode" is the fastets, ot maybe the one without the XmlReadMode, and
using a XmlTextReader.
But there are different ways to open the XmlTextReader, and different ways
for the xmlReadMode, etc...

So this makes the total to hundreds of ways to do it. so testing one after
another would take to much time. I just hink there mya be a 'right'
solution
out there...

Pieter


Stephany Young said:
The easiest way to find out is try them.


DraguVaso said:
Hi,

I should use XML to synchronize the data from different (VB.NET)
applications, and I was just wondering which Overloads of these functions
( ReadXmlSchema, ReadXml and WriteXml) goes the fastest? I don't think the
ReadXMLSchema would give a lot of difference, but maybe the overlaods
of
ReadXml and WriteXml will. Especially with larges files/datatables...

Should I use the IO.Stream? The XmlReader/XmlWriter?

Any help would be really appreciated!

Thanks a lot in advance,

Pieter


The overloads:

Reads the XML schema from the specified Stream into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(Stream)
Reads the XML schema from the specified file into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(String)
Reads the XML schema from the specified TextReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(TextReader)
Reads the XML schema from the specified XmlReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(XmlReader)

Reads XML schema and data into the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Function ReadXml(Stream) As XmlReadMode
Reads XML schema and data into the DataSet using the specified file.
[Visual Basic] Overloads Public Function ReadXml(String) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader.
[Visual Basic] Overloads Public Function ReadXml(TextReader) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader.
[Visual Basic] Overloads Public Function ReadXml(XmlReader) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.Stream and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(Stream, XmlReadMode)
As
XmlReadMode
Reads XML schema and data into the DataSet using the specified file and
XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(String, XmlReadMode)
As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(TextReader, XmlReadMode)
As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(XmlReader,
XmlReadMode)
As
XmlReadMode


Writes the current data for the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Sub WriteXml(Stream)
Writes the current data for the DataSet to the specified file.
[Visual Basic] Overloads Public Sub WriteXml(String)
Writes the current data for the DataSet using the specified TextWriter.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter)
Writes the current data for the DataSet to the specified XmlWriter.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter)
Writes the current data, and optionally the schema, for the DataSet using
the specified System.IO.Stream and XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(Stream, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet to the
specified file using the specified XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(String, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified TextWriter and XmlWriteMode. To write the schema, set the
value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified XmlWriter and XmlWriteMode. To write the schema, set the
value
for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter, XmlWriteMode)
 
C

Cor Ligthert

Pieter,

Although I have as well no answer, what is your source I think that that is
something that you should tell as well?

Internet, DiskFile etc.

Cor
 
D

DraguVaso

Hehehe :) You really didn't sleep too wel did you? :)
So you are convinced that evrybody who's asking something on a newsgroup is
just too lazy to search him/herself, and hopes somebody else is going to
work for him/her? I think that says a lot more about you than it does about
me...
:)

Nevertheless, I don't think that's the appropriate place to have discussions
like this, so it would still be fine if somebody could confirm/reject my
supposition?

thanks,

Pieter


Stephany Young said:
So you expect others to try it out for you and report back?

If you are too lazy to try write a few lines of code and try it for
yourself, then you aren't going to learn much.


DraguVaso said:
Thanks, you didn't sleep too well thisn ight I guess? ;-)

It would jsut be nice if anybody couldgive me tha right answer :) I think
the "Overloads Public Function ReadXml(XmlReader, XmlReadMode) As
XmlReadMode" is the fastets, ot maybe the one without the XmlReadMode, and
using a XmlTextReader.
But there are different ways to open the XmlTextReader, and different ways
for the xmlReadMode, etc...

So this makes the total to hundreds of ways to do it. so testing one after
another would take to much time. I just hink there mya be a 'right'
solution
out there...

Pieter


Stephany Young said:
The easiest way to find out is try them.


Hi,

I should use XML to synchronize the data from different (VB.NET)
applications, and I was just wondering which Overloads of these functions
( ReadXmlSchema, ReadXml and WriteXml) goes the fastest? I don't
think
the
ReadXMLSchema would give a lot of difference, but maybe the overlaods
of
ReadXml and WriteXml will. Especially with larges files/datatables...

Should I use the IO.Stream? The XmlReader/XmlWriter?

Any help would be really appreciated!

Thanks a lot in advance,

Pieter


The overloads:

Reads the XML schema from the specified Stream into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(Stream)
Reads the XML schema from the specified file into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(String)
Reads the XML schema from the specified TextReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(TextReader)
Reads the XML schema from the specified XmlReader into the DataSet.
[Visual Basic] Overloads Public Sub ReadXmlSchema(XmlReader)

Reads XML schema and data into the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Function ReadXml(Stream) As XmlReadMode
Reads XML schema and data into the DataSet using the specified file.
[Visual Basic] Overloads Public Function ReadXml(String) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader.
[Visual Basic] Overloads Public Function ReadXml(TextReader) As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader.
[Visual Basic] Overloads Public Function ReadXml(XmlReader) As XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.Stream and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(Stream, XmlReadMode)
As
XmlReadMode
Reads XML schema and data into the DataSet using the specified file a nd
XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(String, XmlReadMode)
As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.IO.TextReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(TextReader, XmlReadMode)
As
XmlReadMode
Reads XML schema and data into the DataSet using the specified
System.Xml.XmlReader and XmlReadMode.
[Visual Basic] Overloads Public Function ReadXml(XmlReader,
XmlReadMode)
As
XmlReadMode


Writes the current data for the DataSet using the specified
System.IO.Stream.
[Visual Basic] Overloads Public Sub WriteXml(Stream)
Writes the current data for the DataSet to the specified file.
[Visual Basic] Overloads Public Sub WriteXml(String)
Writes the current data for the DataSet using the specified TextWriter.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter)
Writes the current data for the DataSet to the specified XmlWriter.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter)
Writes the current data, and optionally the schema, for the DataSet using
the specified System.IO.Stream and XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(Stream, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet
to
the
specified file using the specified XmlWriteMode. To write the schema, set
the value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(String, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified TextWriter and XmlWriteMode. To write the schema, set the
value for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(TextWriter, XmlWriteMode)
Writes the current data, and optionally the schema, for the DataSet using
the specified XmlWriter and XmlWriteMode. To write the schema, set the
value
for the XMLWriteMode parameter to WriteSchema.
[Visual Basic] Overloads Public Sub WriteXml(XmlWriter, XmlWriteMode)
 
D

DraguVaso

Hi Cor,

Everything allright?
It should be fore the interfacte between a File and a Dataset...
So you have a DataSet, you put it in an Xml-file, send it, and the other
partie just reads ir backin a DataSet.

Pieter
 
C

Cor Ligthert

Pieter,

You understand it probably,

I never took any check to see how fast it is.
I do maximum

\\\
ds.xmlwrite("filepath", XmlWriteMode.WriteSchema)
///
and

\\\
ds.xmlread("filepath")
///

By disk IO, do I never think what is fast, most time is consumed by that
disk itself.

Just my thought,

Cor
 
P

Paul Hatcher

One point I found out recently is that if you are using a
XmlValidatingReader and you are processing more than one file of the same
type, then it's definitely worthwhile building an XmlSchemaCollection and
passing that to the validating reader.

In my test suite, this saved over 60Mb of memory allocations.

Paul
 
J

Jay B. Harlow [MVP - Outlook]

Dragu,
| Should I use the IO.Stream? The XmlReader/XmlWriter?
I would recommend the one that is appropriate to what you are doing! If you
only have a path in a string, I would recommend ReadXmlSchema(String), if
you already has a Stream I would recommend ReadXmlSchema(Stream),

I would not be concerned about "which goes the fastest" until that routine
is proven to be a performance problem (via profiling with CLR profiler or
similar tool).

As I would expect the methods to be implemented in terms of each other,
specifically in terms of ReadXmlSchema(XmlReader) being the one that is
ultimately used.

In other words I would expect the implementation to be something like:

Sub ReadXmlSchema(ByVal fileName As String)
Dim reader As New XmlTextReader(fileName)
Try
ReadXmlSchema(reader)
Finally
reader.Close()
End Try
End Sub

Sub ReadXmlSchema(ByVal stream As Stream)
Dim reader As New XmlTextReader(stream)
Try
ReadXmlSchema(reader)
Finally
reader.Close()
End Try
End Sub

Sub ReadXmlSchema(ByVal reader As TextReader)
Dim xmlReader As New XmlTextReader(reader)
Try
ReadXmlSchema(reader)
Finally
reader.Close()
End Try
End Sub

Sub ReadXmlSchema(ByVal reader As XmlReader)
' actually read the Xml Schema from...
End Sub


Of course there is also the 80/20 rule. That is 80% of the execution time of
your program is spent in 20% of your code. I will optimize (worry about
performance, memory consumption) the 20% once that 20% has been identified &
proven to be a performance problem via profiling (CLR Profiler is one
profiling tool).

For info on the 80/20 rule & optimizing only the 20% see Martin Fowler's
article "Yet Another Optimization Article" at
http://martinfowler.com/ieeeSoftware/yetOptimization.pdf



Further as Paul suggests, based on the options you use to create the
parameters (such as creating an XmlValidatingReader instead of a
XmlTextReader) your performance will vary. So as Stephany suggests you
really need to try them in the context of your program to see which is
faster!


Also rather then worry about which is faster per se I would consider where I
was writing to & reading from. For example can I afford to load the schema
once & keep it in a MemoryStream or a String & pass a MemoryStream to
ReadXmlSchema(Steam), or StringReader to ReadXmlSchema(TextReader) instead
of saving & reading from disk... Which now becomes a question of how the
data is "transmitted" between the applications. Disk, NetworkStream,
Clipboard, other...

Hope this helps
Jay




| Hi,
|
| I should use XML to synchronize the data from different (VB.NET)
| applications, and I was just wondering which Overloads of these functions
| ( ReadXmlSchema, ReadXml and WriteXml) goes the fastest? I don't think the
| ReadXMLSchema would give a lot of difference, but maybe the overlaods of
| ReadXml and WriteXml will. Especially with larges files/datatables...
|
| Should I use the IO.Stream? The XmlReader/XmlWriter?
|
| Any help would be really appreciated!
|
| Thanks a lot in advance,
|
| Pieter
|
|
| The overloads:
|
| Reads the XML schema from the specified Stream into the DataSet.
| [Visual Basic] Overloads Public Sub ReadXmlSchema(Stream)
| Reads the XML schema from the specified file into the DataSet.
| [Visual Basic] Overloads Public Sub ReadXmlSchema(String)
| Reads the XML schema from the specified TextReader into the DataSet.
| [Visual Basic] Overloads Public Sub ReadXmlSchema(TextReader)
| Reads the XML schema from the specified XmlReader into the DataSet.
| [Visual Basic] Overloads Public Sub ReadXmlSchema(XmlReader)
|
<<snip>>
 
D

DraguVaso

Thanks a lot for the nice explication and helpfull hints!

Pieter

Jay B. Harlow said:
Dragu,
| Should I use the IO.Stream? The XmlReader/XmlWriter?
I would recommend the one that is appropriate to what you are doing! If you
only have a path in a string, I would recommend ReadXmlSchema(String), if
you already has a Stream I would recommend ReadXmlSchema(Stream),

I would not be concerned about "which goes the fastest" until that routine
is proven to be a performance problem (via profiling with CLR profiler or
similar tool).

As I would expect the methods to be implemented in terms of each other,
specifically in terms of ReadXmlSchema(XmlReader) being the one that is
ultimately used.

In other words I would expect the implementation to be something like:

Sub ReadXmlSchema(ByVal fileName As String)
Dim reader As New XmlTextReader(fileName)
Try
ReadXmlSchema(reader)
Finally
reader.Close()
End Try
End Sub

Sub ReadXmlSchema(ByVal stream As Stream)
Dim reader As New XmlTextReader(stream)
Try
ReadXmlSchema(reader)
Finally
reader.Close()
End Try
End Sub

Sub ReadXmlSchema(ByVal reader As TextReader)
Dim xmlReader As New XmlTextReader(reader)
Try
ReadXmlSchema(reader)
Finally
reader.Close()
End Try
End Sub

Sub ReadXmlSchema(ByVal reader As XmlReader)
' actually read the Xml Schema from...
End Sub


Of course there is also the 80/20 rule. That is 80% of the execution time of
your program is spent in 20% of your code. I will optimize (worry about
performance, memory consumption) the 20% once that 20% has been identified &
proven to be a performance problem via profiling (CLR Profiler is one
profiling tool).

For info on the 80/20 rule & optimizing only the 20% see Martin Fowler's
article "Yet Another Optimization Article" at
http://martinfowler.com/ieeeSoftware/yetOptimization.pdf



Further as Paul suggests, based on the options you use to create the
parameters (such as creating an XmlValidatingReader instead of a
XmlTextReader) your performance will vary. So as Stephany suggests you
really need to try them in the context of your program to see which is
faster!


Also rather then worry about which is faster per se I would consider where I
was writing to & reading from. For example can I afford to load the schema
once & keep it in a MemoryStream or a String & pass a MemoryStream to
ReadXmlSchema(Steam), or StringReader to ReadXmlSchema(TextReader) instead
of saving & reading from disk... Which now becomes a question of how the
data is "transmitted" between the applications. Disk, NetworkStream,
Clipboard, other...

Hope this helps
Jay




| Hi,
|
| I should use XML to synchronize the data from different (VB.NET)
| applications, and I was just wondering which Overloads of these functions
| ( ReadXmlSchema, ReadXml and WriteXml) goes the fastest? I don't think the
| ReadXMLSchema would give a lot of difference, but maybe the overlaods of
| ReadXml and WriteXml will. Especially with larges files/datatables...
|
| Should I use the IO.Stream? The XmlReader/XmlWriter?
|
| Any help would be really appreciated!
|
| Thanks a lot in advance,
|
| Pieter
|
|
| The overloads:
|
| Reads the XML schema from the specified Stream into the DataSet.
| [Visual Basic] Overloads Public Sub ReadXmlSchema(Stream)
| Reads the XML schema from the specified file into the DataSet.
| [Visual Basic] Overloads Public Sub ReadXmlSchema(String)
| Reads the XML schema from the specified TextReader into the DataSet.
| [Visual Basic] Overloads Public Sub ReadXmlSchema(TextReader)
| Reads the XML schema from the specified XmlReader into the DataSet.
| [Visual Basic] Overloads Public Sub ReadXmlSchema(XmlReader)
|
<<snip>>
 
J

jason

christ man, one of the whole points of technical newsgroups is to save
time by learning from others' experiences. if someone knows the answer
and is willing to share, why not ask?

if you don't know, all you have to do is not reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top