This is a performance summary of 2 implementations of Element interface in AXIOM.
One implementation uses java.util.ArrayList
to hold child elements while the other
keeps pointers to the first child and next/previous sibling in each element-- thus
burning in the linked list into Element class itself. The latter as you know is what
is used in AXIOM at the moment. However, recently there have been some discussion
as to whether that is the right way to go...
Each row in the table below shows one set of test results. Each test comprised of first
creating an Element, then adding a number of child elements and finally traversing all
the child elements added. The number of child elements added and the number
of traversals performed have been varied. Two approaches were used for traversing
the children when using an ArrayList
. One used an Iterator
while the other used
a 'for' loop. The details can be found by inspecting the code
(ALElement, LLElement).
Have a look at the Tester
for info on how
the test was carried out.
children | traversals | using iterator | time(ms)/LLElement | time(ms)/ALElement |
1000 | 1 | no | 0 | 0 |
10000 | 1 | no | 2 | 22 |
100 | 100 | no | 0 | 0 |
100 | 1000 | no | 0 | 2 |
100 | 10000 | no | 6 | 27 |
100 | 100 | yes | 0 | 0 |
100 | 1000 | yes | 0 | 7 |
100 | 10000 | yes | 6 | 72 |