I decided to stress test
Sun (Project
X) and IBM's (XML Parser for Java) parser because many of our readers
have
asked which parser is better. I hope to answer part of that question in
this article.
I have written a program (IBMvsSUN.java)
which tests only the DOM API implementation on the Sun and IBM parsers.
This program generates an XML document and measures the time it takes
for
the XML parsers to read the document and convert it into a DOM object.
This program should be used to compare the relative performance of the
Sun parser to the IBM parser, as actual values vary from machine to
machine.
It should give you a good feel for which one is faster than the other.
The test results will vary
depending on the machine
this test program is run on. I ran it on a Pentium II 300 Mhz
processor
machine, with 128MB of Memory and Windows NT 4.0 SP3. When the test
program
was run on my machine it produced the following results:
XML file size
(in KB)
|
Sun Parser
(in seconds)
|
IBM Parser
(in seconds)
|
|
100 KB
|
1.4
|
2.6
|
|
500 KB
|
2.4
|
7.1
|
|
1 MB
|
3.7
|
13.7
|
|
2 MB
|
6.3
|
27.3
|
|
3 MB
|
8.8
|
40.0
|
|
4 MB
|
12.5
|
53.0
|
|
5 MB
|
23.7
|
OutOfMemory
exception
|
|
10 MB
|
30.0
|
""
|
|
15 MB
|
54.0
|
""
|
|
20 MB
|
OutOfMemory
exception
|
""
|

As you can see from the test
results, the Sun Project
X XML Parser is definately better than the IBM offering, for creating
DOM
objects anyway. Other features of the parser like XPointer and XLink
implementation
were not tested and neither was DOM manipulation (after creation).
The is only one source
file called IBMvsSUN.java.
An XML document is created on the fly by this program. To change
the size of the XML file, you can change the increment integer in the
constructor
( IbmVsSun() ) in IBMvsSUN.java. When you
change
the XML file size you need to re-compile the sample program and run it
again.
For example, when the increment
is set to 2 (which
generates a 200KB XML document), this program prints followings at
console
when it runs:
:: For 200 KB of XML document ::
Sun Parser took: 1592 milli-seconds
IBM Parser took: 3946 milli-seconds
Here is the source code for the
both parsers: IBMvsSUN.zip
Please go to the tools
sections to actually download the Parsers themselves.
I hope you enjoyed this article,
I will have more
comprehensive testing programs and data avaiable soon. So stay tuned
and
keep coming back :). Click here
to send me any feedback/comments.