473,657 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

odd performance question - xml parsing

Hi...

We've been doing some basic performance testing comparing asp, asp.net,
mono, and php. One of the basic tests is on simply parsing an xml document
and streaming the result back to the client.

I never would have thought of it, but someone in our group had heard that
using XmlDocument.Loa d (Server.MapPath (file));
was slower than actually creating the stream, the XmlTextReader, and passing
the reader to the XmlDocument.Loa d();.

I've tried it, and darn if he wasn't right.

System.Xml.XmlD ocument DOMObj = new System.Xml.XmlD ocument();
System.IO.Strea mReader stream = new System.IO.Strea mReader
(Server.MapPath ("file.xml") );
System.Xml.XmlT extReader reader = new System.Xml.XmlT extReader(strea m);
reader.Whitespa ceHandling = System.Xml.Whit espaceHandling. None;
DOMObj.Load(rea der);

was 5% faster than

System.Xml.XmlD ocument DOMObj = new System.Xml.XmlD ocument();
System.Xml.XmlT extReader reader = new
System.Xml.XmlT extReader(Serve r.MapPath ("file.xml") );
reader.Whitespa ceHandling = System.Xml.Whit espaceHandling. None;
DOMObj.Load(rea der);

which was 20% faster than
System.Xml.XmlD ocument DOMObj = new System.Xml.XmlD ocument();
DOMObj.Preserve Whitespace = true;
DOMObj.Load(Ser ver.MapPath("fi le.xml"));

I can't think of any reason why it's so much faster to manually create your
own stream and XmlTextReader rather than letting XmlDocument figure out the
fastest way to process the document.

Any ideas?

Thanks
_mark

Jan 17 '06 #1
2 1410
doc.load(filena me) - creates a validating xml reader, which is why its so
slow

new XmlTextReader(f ilename) - expects a uri, not a filename. if no protocol
is specified, then its converted to a file based uri (file://filename), then
opened as a uri resource. this transalation requires serveral directory
lookups.

new XmlTextReader(r eader) - just read the stream of bytes from the reader.
if you pick one optimized for file opening and reading, its fastest.

-- bruce (sqlwork.com)
"Mark" <mm******@nospa m.nospam> wrote in message
news:34******** *************** ***********@mic rosoft.com...
Hi...

We've been doing some basic performance testing comparing asp, asp.net,
mono, and php. One of the basic tests is on simply parsing an xml
document
and streaming the result back to the client.

I never would have thought of it, but someone in our group had heard that
using XmlDocument.Loa d (Server.MapPath (file));
was slower than actually creating the stream, the XmlTextReader, and
passing
the reader to the XmlDocument.Loa d();.

I've tried it, and darn if he wasn't right.

System.Xml.XmlD ocument DOMObj = new System.Xml.XmlD ocument();
System.IO.Strea mReader stream = new System.IO.Strea mReader
(Server.MapPath ("file.xml") );
System.Xml.XmlT extReader reader = new System.Xml.XmlT extReader(strea m);
reader.Whitespa ceHandling = System.Xml.Whit espaceHandling. None;
DOMObj.Load(rea der);

was 5% faster than

System.Xml.XmlD ocument DOMObj = new System.Xml.XmlD ocument();
System.Xml.XmlT extReader reader = new
System.Xml.XmlT extReader(Serve r.MapPath ("file.xml") );
reader.Whitespa ceHandling = System.Xml.Whit espaceHandling. None;
DOMObj.Load(rea der);

which was 20% faster than
System.Xml.XmlD ocument DOMObj = new System.Xml.XmlD ocument();
DOMObj.Preserve Whitespace = true;
DOMObj.Load(Ser ver.MapPath("fi le.xml"));

I can't think of any reason why it's so much faster to manually create
your
own stream and XmlTextReader rather than letting XmlDocument figure out
the
fastest way to process the document.

Any ideas?

Thanks
_mark

Jan 18 '06 #2
Thanks for the great answer, Bruce...

-Mark
Jan 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
2744
by: lkrubner | last post by:
I've got a PHP application that's 2 megs in size. Of that, my guess is 200k-400k is comments. Do they impose a performance hit? I've been postponing any kind of optimization, but at some point I'll have to do it. Is taking out the comments worth it? Of all the optimizations I can do, where should it rank?
7
2200
by: Dennis Roberts | last post by:
I have a script to parse a dns querylog and generate some statistics. For a 750MB file a perl script using the same methods (splits) can parse the file in 3 minutes. My python script takes 25 minutes. It is enough of a difference that unless I can figure out what I did wrong or a better way of doing it I might not be able to use python (since most of what I do is parsing various logs). The main reason to try python is I had to look at...
1
1458
by: amit | last post by:
Hello, Is there any kind of performance differences to the different ways of embedding python? PyEval_EvalCode() PyRun_SimpleFile() PyObject_CallObject() Thanks
3
6057
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C# Application. My tree view represents an hierarchical view of Parent Nodes and projects where in a projectnode can be added to any ParentNode and hence we may have a project node added to 100 Parent nodes. In this one, I have an operation of Renaming a Project Node. So whenever I am doing the...
15
5548
by: Sion Arrowsmith | last post by:
I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML (it's taking 100% CPU on one or other end of the connection and accounting for well over 50% of the total call time, to the extent that it's having a greater impact on performance than user interaction)....
3
1629
by: Toadfather | last post by:
Hi all Existing COM ATL DLL wrapping a C++ library. Interoping from a C# application, passing a large string containng XML (5-130kb). Need to significantly improve performance of both the interoping and the performance of the native functions (performance critical app). Opinions sought on most worthwhile course of action...have identified 4 options...
3
3845
by: rony | last post by:
Hi, I am looking for component which allows me to parse my xml file. the reason i am asking this, is because my xml files are huge it can reach as far as 1GB more or less. the time to parse such a file is something like 5 Hours. Now i am using the XmlRead, XmlNode ... (I do not load the file to the memory). Can you suggest better components to use? ** I tried SAX but i couldn't understand how it works, because there is
4
1516
by: skotapal | last post by:
Hello I manage a web based VB .net application. This application has 3 components: 1. Webapp (this calls the executibles) 2. database 3. business logic is contained in individual exe application that get called in a sequence to do some heavy calculations (mainly DB operations with in memory datasets)
2
1964
by: Paul McGuire | last post by:
I just ran my pyparsing unit tests with the latest Python 2.6b1 (labeled internally as Python 2.6a3 - ???), and the current 1.5.0 version of pyparsing runs with no warnings or regressions. I was pleasantly surprised by the improved performance. The most complex parser I have is the Verilog parser, and I have just under 300 sample input files, so the test gets a chance to run over a range of code and source inputs. Here are the...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.