[MonoTouch] Slow XML Parsing Performance
Phil Jepsen
jepsen at gmail.com
Fri Nov 13 01:08:36 EST 2009
I have a WCF service method which returns Gzipped XML to my app.
The method returns ~1000 records, producing an uncompressed file size of
~500KB (compressed is ~64KB).
To process this XML I am using the XmlReader which is the Fastest method.
I initially tried loading the entire Xml Doc into memory (XDocument.Parse)
and using Linq to objects, but that is almost twice as slow.
To get the stream takes ~8secs, to process the Xml is ~35secs.
This is way too slow. The simulator in comparison takes 0.3 seconds to
parse the XML. From what I've been reading on the web I should be getting
better
parsing performance. Also of note is that I am doing all my data access in
background thread.
Example Code:
Stream stream = new GZipInputStream(response.GetResponseStream());
using (XmlReader reader = XmlReader.Create(stream, settings)) {
reader.ReadToFollowing("Data");
while (!reader.EOF)
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
{
if (reader.Name == "Data")
{
XElement el = XElement.ReadFrom(reader) as
XElement;
obj.Add(new Obj( (string) el.Element (ns +
"Name").Value
.....
Please help!
Thanks,
Phil Jepsen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20091112/113bd3e6/attachment.html
More information about the MonoTouch
mailing list