CF SP2 and ReadXML performance

R

Richard Kucia

My app's startup time has always been horrible, so I was looking forward
with great anticipation to CF SP2.
The app reads a single XML file once during its startup, and it stores the
contents in various objects.

I installed CF SP2 (non-developer) on my Dell Axim X5 and timed ReadXML in a
variety of ways. I created a two files, one with and one without an embedded
schema. Then I tried various combinations of ReadXML and XMLReadMode. Here
are the results, in milliseconds:

File and XMLReadMode Elapsed Time in ms
-------------------------- -------------------
NoSchema + Auto 14.129
Schema + Auto 6.782
Schema + Ignore .358
Schema + ReadSchema 5.630
NoSchema + Auto 12.711
NoSchema + Infer 12.146

Typical code for any one of these cases is:
RaiseEvent InitializationStepEvent("User: Reference file: No Schema + Auto")

ReferenceDataSet = New System.Data.DataSet("reference")

fsXML = New System.IO.FileStream(clsCommon.AppPath & "Reference With No
Schema.xml", System.IO.FileMode.Open, IO.FileAccess.Read)

myXmlReader = New System.Xml.XmlTextReader(fsXML) ' Create an XmlTextReader
to read the file

ReferenceDataSet.ReadXml(myXmlReader, System.Data.XmlReadMode.InferSchema)


I believe the Axim is running CF CLR 1.0.3316.0

Can anyone offer an explanation for the truly wide disparity among these
results? I'd be happy to send the files to anyone wishing to reproduce these
test results.

Richard Kucia
 
I

Ilya Tumanov [MS]

Richard,

Please see inline...

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Richard Kucia" <[email protected]>
Subject: CF SP2 and ReadXML performance
Date: Tue, 2 Mar 2004 17:18:05 -0500
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: 146.cleveland-11-13rs.oh.dial-access.att.net 12.75.70.146
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.compactframework:47475
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

My app's startup time has always been horrible, so I was looking forward
with great anticipation to CF SP2.
The app reads a single XML file once during its startup, and it stores the
contents in various objects.

I installed CF SP2 (non-developer) on my Dell Axim X5 and timed ReadXML in a
variety of ways. I created a two files, one with and one without an embedded
schema. Then I tried various combinations of ReadXML and XMLReadMode. Here
are the results, in milliseconds:

File and XMLReadMode Elapsed Time in ms
-------------------------- -------------------
NoSchema + Auto 14.129

Schema inferred, this is the slowest way to go and it should be generally
avoided.
However, in case of very small XML it could be faster than loading schema.
Schema + Auto 6.782

Schema is loaded first; data is loaded based on schema.
This is second best to use. Best one is to have schema already in the
DataSet.
Schema code is a big and complicated one; it takes few seconds to JIT and
execute it.
Schema + Ignore .358

This is fast as it's doing nothing.
Since you do not have schema in the DataSet and you choose to ignore schema
in XML, no data is actually loaded.
Schema + ReadSchema 5.630

Same as Schema + Auto. If you running tests in a batch, it might appear a
bit faster as code is preJITed already.
NoSchema + Auto 12.711

Schema inferred. Again, might appear faster because code has been preJITed.
NoSchema + Infer 12.146

Same as above, done in about the same time.
Typical code for any one of these cases is:
RaiseEvent InitializationStepEvent("User: Reference file: No Schema + Auto")

ReferenceDataSet = New System.Data.DataSet("reference")

fsXML = New System.IO.FileStream(clsCommon.AppPath & "Reference With No
Schema.xml", System.IO.FileMode.Open, IO.FileAccess.Read)

myXmlReader = New System.Xml.XmlTextReader(fsXML) ' Create an XmlTextReader
to read the file

ReferenceDataSet.ReadXml(myXmlReader, System.Data.XmlReadMode.InferSchema)


I believe the Axim is running CF CLR 1.0.3316.0

Can anyone offer an explanation for the truly wide disparity among these
results? I'd be happy to send the files to anyone wishing to reproduce these
test results.

There's no disparity, it's in fact very consistent.
It takes 12-14 seconds to infer schema, 5-7 seconds to load schema and
data, .4 seconds to scan the file and do nothing.
If you preJIT the code, time will probably match to a fractions of a second.
 
Top