Skip to content

Commit a16776e

Browse files
committed
DOM benchmarks: add links to benchmark code
1 parent 882fbcb commit a16776e

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

dom-mark.html

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ <h2>Overview</h2>
4646
<li>Java: <a href="https://adoptium.net/">Adoptium's Temurin OpenJDK</a><a href="#jdk_note">*</a> 21.</li>
4747
<li>JMH: 1.37.</li>
4848
<li>css4j: <a href="https://mvnrepository.com/artifact/io.sf.carte/css4j">6.1.1</a>.</li>
49-
<li>validator.nu htmlparser: <a href="https://central.sonatype.com/artifact/nu.validator/htmlparser">1.4.16</a>.</li>
49+
<li>css4j-dom4j: <a href="https://mvnrepository.com/artifact/io.sf.carte/css4j-dom4j">6.1</a>.</li>
5050
<li>dom4j: <a href="https://central.sonatype.com/artifact/org.dom4j/dom4j">2.2.0</a>.</li>
51+
<li>validator.nu htmlparser: <a href="https://central.sonatype.com/artifact/nu.validator/htmlparser">1.4.16</a>.</li>
5152
<li>Jsoup: <a href="https://central.sonatype.com/artifact/org.jsoup/jsoup">1.21.2</a>.</li>
5253
</ul>
5354
</div>
54-
<p>The tables and charts were generated by <a href="https://github.com/css4j/carte">Carte</a> (look for the <code>BenchmarkChartWriter</code>
55-
class and the <code>examples</code> folder in the <code>carte-jmh</code> module). The grey lines at the top of the bars give the amplitude of the estimated error.</p>
55+
<p>The tables and charts were generated by <a href="https://github.com/css4j/carte">Carte</a> (look for
56+
the <a href="https://github.com/css4j/carte/blob/master/carte-jmh/src/io/sf/carte/report/jmh/BenchmarkChartWriter.java"><code>BenchmarkChartWriter</code></a>
57+
class and the <a
58+
href="https://github.com/css4j/carte/tree/master/carte-jmh/examples"><code>examples</code></a> folder in
59+
the <code>carte-jmh</code> module, especially the <a
60+
href="https://github.com/css4j/carte/blob/master/carte-jmh/examples/dom-benchmark.xml"><code>dom-benchmark.xml</code></a>
61+
configuration file). The grey lines at the top of the bars give the amplitude of the estimated error.</p>
5662
<p>The computer has an Intel® Core™ i5-1035G7 CPU and 8GB of RAM. Unfortunately, being a laptop processor it is affected by thermal management,
5763
which may explain some relatively large error intervals.</p>
5864
<p id="jdk_note" class="note">(*) Note: one of the tested DOM implementations is the one that comes bundled with the JDK (identified as "JDK" in the graphics), and it has been observed
@@ -62,6 +68,7 @@ <h2>Overview</h2>
6268
<h2>Build HTML documents</h2>
6369
<p>Measures the speed at which the <a href="https://about.validator.nu/htmlparser/">validator.nu HTML parser</a> can parse a small document (38 KB HTML) into a few DOM implementations.
6470
As a reference, they are compared to the same document parsed by Jsoup.</p>
71+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/HTMLBuildBenchmark.java"><code>HTMLBuildBenchmark</code></a>.</p>
6572
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
6673
<title>HTML build benchmark</title><defs>
6774
<clipPath id="html-build-cut-scale-shadow">
@@ -167,6 +174,7 @@ <h2>Build HTML documents</h2>
167174
<div class="tema" id="xml-build-small">
168175
<h2>Build small XML documents</h2>
169176
<p>The SAX parser that comes bundled with the JDK is used to parse and build a document from a small XHTML file (38 KB).</p>
177+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/XMLBuildSmallBenchmark.java"><code>XMLBuildSmallBenchmark</code></a>.</p>
170178
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
171179
<title>XML build benchmark</title><defs>
172180
<clipPath id="xml-build-small-cut-scale-shadow">
@@ -270,6 +278,7 @@ <h2>Build small XML documents</h2>
270278
<div class="tema" id="xml-build">
271279
<h2>Build XML documents</h2>
272280
<p>The SAX parser that comes bundled with the JDK is used to parse and build a document (1MB file).</p>
281+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/XMLBuildBenchmark.java"><code>XMLBuildBenchmark</code></a>.</p>
273282
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
274283
<title>XML build benchmark</title><defs>
275284
<clipPath id="xml-build-cut-scale-shadow">
@@ -373,6 +382,7 @@ <h2>Build XML documents</h2>
373382
<div class="tema" id="traversal-small-next">
374383
<h2>DOM traversal: <code>getFirstChild()/getNextSibling() (small file)</code></h2>
375384
<p>Count the nodes of a 38kB XHTML document, using a combination of <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#getFirstChild()">getFirstChild()</a>/<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#getNextSibling()">getNextSibling()</a></code> to traverse it.</p>
385+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMSiblingTraversalSmallMark.java"><code>DOMSiblingTraversalSmallMark</code></a>.</p>
376386
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
377387
<title>DOM Traversal: NextSibling (small file)</title><defs>
378388
<clipPath id="traversal-small-next-cut-scale-shadow">
@@ -467,6 +477,7 @@ <h2>DOM traversal: <code>getFirstChild()/getNextSibling() (small file)</code></h
467477
<div class="tema" id="traversal-small-prev">
468478
<h2>DOM traversal: <code>getLastChild()/getPreviousSibling() (small file)</code></h2>
469479
<p>Count the nodes of a 38kB XHTML document, using a combination of <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#getLastChild()">getLastChild()</a>/<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#getPreviousSibling()">getPreviousSibling()</a></code> to traverse it.</p>
480+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMSiblingTraversalSmallMark.java"><code>DOMSiblingTraversalSmallMark</code></a>.</p>
470481
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
471482
<title>DOM Traversal: PreviousSibling (small file)</title><defs>
472483
<clipPath id="traversal-small-prev-cut-scale-shadow">
@@ -557,6 +568,7 @@ <h2>DOM traversal: <code>getLastChild()/getPreviousSibling() (small file)</code>
557568
<div class="tema" id="traversal-next">
558569
<h2>DOM traversal: <code>getFirstChild()/getNextSibling()</code></h2>
559570
<p>Count the nodes of an XML document, using a combination of <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#getFirstChild()">getFirstChild()</a>/<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#getNextSibling()">getNextSibling()</a></code> to traverse it.</p>
571+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMSiblingTraversalMark.java"><code>DOMSiblingTraversalMark</code></a>.</p>
560572
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
561573
<title>DOM Traversal: NextSibling</title><defs>
562574
<clipPath id="traversal-next-cut-scale-shadow">
@@ -651,6 +663,7 @@ <h2>DOM traversal: <code>getFirstChild()/getNextSibling()</code></h2>
651663
<div class="tema" id="traversal-prev">
652664
<h2>DOM traversal: <code>getLastChild()/getPreviousSibling()</code></h2>
653665
<p>Count the nodes of an XML document, using a combination of <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#getLastChild()">getLastChild()</a>/<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#getPreviousSibling()">getPreviousSibling()</a></code> to traverse it.</p>
666+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMSiblingTraversalMark.java"><code>DOMSiblingTraversalMark</code></a>.</p>
654667
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
655668
<title>DOM Traversal: PreviousSibling</title><defs>
656669
<clipPath id="traversal-prev-cut-scale-shadow">
@@ -741,6 +754,7 @@ <h2>DOM traversal: <code>getLastChild()/getPreviousSibling()</code></h2>
741754
<div class="tema" id="nodeiterator-small">
742755
<h2>DOM traversal: <code>NodeIterator</code> (small file)</h2>
743756
<p>Count the elements of a 38kB XHTML document traversed by a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/traversal/NodeIterator.html"><code>NodeIterator</code></a>.</p>
757+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMTraversalSmallMark.java"><code>DOMTraversalSmallMark</code></a>.</p>
744758
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
745759
<title>DOM Traversal: NodeIterator (small file)</title><defs>
746760
<clipPath id="nodeiterator-small-cut-scale-shadow">
@@ -819,6 +833,7 @@ <h2>DOM traversal: <code>NodeIterator</code> (small file)</h2>
819833
<div class="tema" id="nodeiterator">
820834
<h2>DOM traversal: <code>NodeIterator</code></h2>
821835
<p>Count the elements of an XML document traversed by a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/traversal/NodeIterator.html"><code>NodeIterator</code></a>.</p>
836+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMTraversalMark.java"><code>DOMTraversalMark</code></a>.</p>
822837
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
823838
<title>DOM Traversal: NodeIterator</title><defs>
824839
<clipPath id="nodeiterator-cut-scale-shadow">
@@ -907,6 +922,7 @@ <h2>DOM traversal: <code>NodeIterator</code></h2>
907922
<div class="tema" id="treewalker-small">
908923
<h2>DOM traversal: <code>TreeWalker</code> (small file)</h2>
909924
<p>Count the elements of a 38kB XHTML document traversed by a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/traversal/TreeWalker.html"><code>TreeWalker</code></a>.</p>
925+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMTraversalSmallMark.java"><code>DOMTraversalSmallMark</code></a>.</p>
910926
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
911927
<title>DOM Traversal: TreeWalker (small file)</title><defs>
912928
<clipPath id="treewalker-small-cut-scale-shadow">
@@ -985,6 +1001,7 @@ <h2>DOM traversal: <code>TreeWalker</code> (small file)</h2>
9851001
<div class="tema" id="treewalker">
9861002
<h2>DOM traversal: <code>TreeWalker</code></h2>
9871003
<p>Count the elements of an XML document traversed by a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/traversal/TreeWalker.html"><code>TreeWalker</code></a>.</p>
1004+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMTraversalMark.java"><code>DOMTraversalMark</code></a>.</p>
9881005
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
9891006
<title>DOM Traversal: TreeWalker</title><defs>
9901007
<clipPath id="treewalker-cut-scale-shadow">
@@ -1065,6 +1082,7 @@ <h2>DOM traversal: <code>iterator()</code> (small file)</h2>
10651082
<p>Traverse a 38kB XHTML document using native DOM's iterable <a href="https://css4j.github.io/api/latest/io.sf.carte.css4j/io/sf/carte/doc/dom/DOMNode.html#getChildNodes()"><code>getChildNodes()</code></a>,
10661083
DOM4J's <a href="https://dom4j.github.io/javadoc/2.1.4/org/dom4j/Branch.html#nodeIterator--"><code>nodeIterator()</code></a> and Jsoup's
10671084
iterable <a href="https://jsoup.org/apidocs/org/jsoup/nodes/Node.html#childNodes()"><code>childNodes()</code></a>.</p>
1085+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMIteratorSmallMark.java"><code>DOMIteratorSmallMark</code></a>.</p>
10681086
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
10691087
<title>DOM Traversal: child node iterators (small file)</title><defs>
10701088
<clipPath id="iterator-small-cut-scale-shadow">
@@ -1150,6 +1168,7 @@ <h2>DOM traversal: <code>iterator()</code> (small file)</h2>
11501168
<h2>DOM traversal: <code>iterator()</code></h2>
11511169
<p>Traverse an XML document using native DOM's iterable <a href="https://css4j.github.io/api/latest/io.sf.carte.css4j/io/sf/carte/doc/dom/DOMNode.html#getChildNodes()"><code>getChildNodes()</code></a>
11521170
and DOM4J's <a href="https://dom4j.github.io/javadoc/2.1.4/org/dom4j/Branch.html#nodeIterator--"><code>nodeIterator()</code></a>.</p>
1171+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMIteratorMark.java"><code>DOMIteratorMark</code></a>.</p>
11531172
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
11541173
<title>DOM Traversal: child node iterators</title><defs>
11551174
<clipPath id="iterator-cut-scale-shadow">
@@ -1236,6 +1255,7 @@ <h2>DOM traversal: <code>elementIterator()</code> (small file)</h2>
12361255
<p>Traverse a 38kB XHTML document using native DOM's <a href="https://css4j.github.io/api/latest/io.sf.carte.css4j/io/sf/carte/doc/dom/ParentNode.html#elementIterator()"><code>elementIterator()</code></a>,
12371256
DOM4J's <a href="https://dom4j.github.io/javadoc/2.1.4/org/dom4j/Element.html#elementIterator--"><code>elementIterator()</code></a> and Jsoup's
12381257
iterable <a href="https://jsoup.org/apidocs/org/jsoup/select/Elements.html"><code>Elements</code></a>.</p>
1258+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMIteratorSmallMark.java"><code>DOMIteratorSmallMark</code></a>.</p>
12391259
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
12401260
<title>DOM Traversal: element iterators (small file)</title><defs>
12411261
<clipPath id="element-iterator-small-cut-scale-shadow">
@@ -1321,6 +1341,7 @@ <h2>DOM traversal: <code>elementIterator()</code> (small file)</h2>
13211341
<h2>DOM traversal: <code>elementIterator()</code></h2>
13221342
<p>Traverse an XML document using native DOM's <a href="https://css4j.github.io/api/latest/io.sf.carte.css4j/io/sf/carte/doc/dom/ParentNode.html#elementIterator()"><code>elementIterator()</code></a>
13231343
and DOM4J's <a href="https://dom4j.github.io/javadoc/2.1.4/org/dom4j/Element.html#elementIterator--"><code>elementIterator()</code></a>.</p>
1344+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMIteratorMark.java"><code>DOMIteratorMark</code></a>.</p>
13241345
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
13251346
<title>DOM Traversal: element iterators</title><defs>
13261347
<clipPath id="element-iterator-cut-scale-shadow">
@@ -1409,6 +1430,7 @@ <h2>DOM traversal: <code>getElementsByTagName()</code> (small file)</h2>
14091430
<a href="https://dom.spec.whatwg.org/#interface-nodelist"><code>NodeList</code></a> by the <code>item()</code> method, and another
14101431
via the iterator (the returned <code>NodeList</code> implements
14111432
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html"><code>Iterable</code></a>).</p>
1433+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMElementsByTagNameSmallMark.java"><code>DOMElementsByTagNameSmallMark</code></a>.</p>
14121434
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
14131435
<title>DOM getElementsByTagName() (small file)</title><defs>
14141436
<clipPath id="elements-by-tagname-small-cut-scale-shadow">
@@ -1519,6 +1541,7 @@ <h2>DOM traversal: <code>getElementsByTagName()</code></h2>
15191541
<p>Traverse the list given by <code>getElementsByTagName()</code>, this time from a 1MB document. Again, for css4j's native DOM there are two results: one iterating the
15201542
<a href="https://dom.spec.whatwg.org/#interface-nodelist"><code>NodeList</code></a> by the <code>item()</code> method, and another via the iterator
15211543
(the returned <code>NodeList</code> implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html"><code>Iterable</code></a>).</p>
1544+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMElementsByTagNameMark.java"><code>DOMElementsByTagNameMark</code></a>.</p>
15221545
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
15231546
<title>DOM getElementsByTagName()</title><defs>
15241547
<clipPath id="elements-by-tagname-cut-scale-shadow">
@@ -1630,6 +1653,7 @@ <h2>DOM traversal: <code>getElementsByTagName()</code></h2>
16301653
<h2>DOM modification: <code>appendChild()/removeChild()</code></h2>
16311654
<p>Modify the nodes of an XML document by appending elements with <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#appendChild(org.w3c.dom.Node)"><code>appendChild()</code></a> and later removing them with
16321655
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#removeChild(org.w3c.dom.Node)"><code>removeChild()</code></a>.</p>
1656+
<p>Code: <a href="https://github.com/css4j/benchmark/blob/master/src/io/sf/carte/mark/dom/DOMChangeMark.java"><code>DOMChangeMark</code></a>.</p>
16331657
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewBox="0 0 700 500" class="carteitem">
16341658
<title>DOM document modification</title><defs>
16351659
<clipPath id="dom-change-cut-scale-shadow">

0 commit comments

Comments
 (0)