-
Notifications
You must be signed in to change notification settings - Fork 0
/
dom-mark.html
1508 lines (1505 loc) · 104 KB
/
dom-mark.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html lang="en"><head>
<title>CSS4J DOM benchmarks</title>
<link href="basic-c.css" rel="stylesheet" type="text/css" />
<script src="js/indexbuilder-compr.js" type="text/javascript" charset="utf-8"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body id="dom-mark">
<div class="layout">
<div id="hdr01"></div>
<a id="mylinkhome" href="/"><span>CSS4J</span></a>
</div>
<div class="container">
<div class="menu">
<ul class="menulist">
<li><a id="mnuindice" href="/"><span>Home</span></a></li>
<li><a id="mnuusage" href="usage.html"><span>Usage</span></a></li>
<li><a id="mnuapi2" href="api/latest/"><span>Latest API</span></a></li>
<li><a id="mnufaq" href="faq.html"><span>FAQ</span></a></li>
<li><a id="mnubenchmarks" href="benchmarks.html"><span>Benchmarks</span></a></li>
<li class="menulvl2"><div id="mnudommark-sel"><span>DOM mark</span></div></li>
<li class="menulvl2"><a id="mnusacmark" href="sac-mark.html"><span>SAC mark</span></a></li>
<li><a id="mnugithub" href="https://github.com/css4j"><span>Github</span></a></li>
</ul>
</div>
<div class="beforemain"></div>
<div class="main">
<div id="presentacion_top" class="textheader"><span>DOM mark</span></div>
<div class="cos">
<h1>DOM benchmarks</h1>
<div class="tema" id="overview">
<h2>Overview</h2>
<p>The DOM benchmarks measure how fast different DOM implementations are when building and traversing documents:</p>
<ul>
<li><a href="https://github.com/css4j/css4j-dom4j">Css4j-DOM4J</a> module (which subclasses DOM4J).</li>
<li><a href="https://css4j.github.io/api/latest/io.sf.carte.css4j/io/sf/carte/doc/dom/package-summary.html">Css4j's native DOM</a>.</li>
<li>Stand-alone <a href="https://dom4j.github.io/">DOM4J</a>.</li>
<li>JDK's bundled <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/DOMImplementation.html">DOM implementation</a>.</li>
</ul>
<p>As a reference, some of the benchmarks were performed with <a href="https://jsoup.org/">Jsoup</a> which
does not implement DOM but is a popular HTML parser and pseudo-DOM library. It is only being benchmarked when the document's markup is (X)HTML.</p>
<div class="subtema">
<p>The following software versions were used:</p>
<ul>
<li>Java: <a href="https://adoptopenjdk.net/">AdoptOpenJDK</a>* 15.</li>
<li>JMH: 1.26.</li>
<li>css4j: 3.2.</li>
<li>validator.nu htmlparser: <a href="https://search.maven.org/artifact/nu.validator/htmlparser">1.4.16</a>.</li>
<li>dom4j: 2.1.3.</li>
<li>Jsoup: 1.13.1.</li>
</ul>
</div>
<p>The tables and charts were generated by <a href="https://github.com/css4j/carte">Carte</a> (look for the <code>BenchmarkChartWriter</code>
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>
<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,
which may explain some relatively large error intervals.</p>
<p 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
that the version shipped with the Oracle JDK may be faster.</p>
</div>
<div class="tema" id="html-build">
<h2>Build HTML documents</h2>
<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.
As a reference, they are compared to the same document parsed by Jsoup.</p>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>HTML build benchmark</title><defs>
<clipPath id="html-build-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="html-build-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="html-build-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="html-build-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#html-build-caption {
font-size: 13pt;
font-weight: 700;
}
#html-build-subcaption {
font-size: 9pt;
font-weight: 600;
}
#html-build-x-title,#html-build-y-title {
font-size: 10pt;
font-weight: 700;
}
.html-build-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.html-build-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#html-build-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#html-build-projection')" clip-path="url('#html-build-cut-scale-shadow')"/>
<rect id="html-build-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="html-build-caption" x="355" y="22" text-anchor="middle" fill="black">HTML build benchmark</text>
<text id="html-build-subcaption" x="355" y="40" text-anchor="middle" fill="black">38 KB html file, validator.nu parser (except Jsoup)</text>
<rect width="88.0" height="32.9" x="80.5" y="422.1" stroke="#ffffff" stroke-opacity="0.4" filter="url('#html-build-projection')"/>
<rect id="html-build-markBuildCss4jDOM4J" width="88.0" height="32.9" x="80.5" y="422.1" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c04d4d"/>
<rect width="88.0" height="32.9" x="80.5" y="422.1" fill="url('#html-build-reflection')"/>
<line x1="129.3" x2="129.3" y1="420.9" y2="423.1" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="126.7" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j-DOM4J</text>
<rect width="88.0" height="31.4" x="182.1" y="423.6" stroke="#ffffff" stroke-opacity="0.4" filter="url('#html-build-projection')"/>
<rect id="html-build-markBuildDOM" width="88.0" height="31.4" x="182.1" y="423.6" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="88.0" height="31.4" x="182.1" y="423.6" fill="url('#html-build-reflection')"/>
<line x1="230.9" x2="230.9" y1="423.8" y2="424.2" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="228.4" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="88.0" height="31.6" x="283.8" y="423.4" stroke="#ffffff" stroke-opacity="0.4" filter="url('#html-build-projection')"/>
<rect id="html-build-markBuildDOM4J" width="88.0" height="31.6" x="283.8" y="423.4" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#4d4dc0"/>
<rect width="88.0" height="31.6" x="283.8" y="423.4" fill="url('#html-build-reflection')"/>
<line x1="332.6" x2="332.6" y1="422.8" y2="423.2" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="330.1" y="470" class="itemlabel" text-anchor="middle" fill="black">DOM4J</text>
<rect width="88.0" height="30.7" x="385.5" y="424.3" stroke="#ffffff" stroke-opacity="0.4" filter="url('#html-build-projection')"/>
<rect id="html-build-markBuildDOMXHTMLBuilder" width="88.0" height="30.7" x="385.5" y="424.3" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c04dc0"/>
<rect width="88.0" height="30.7" x="385.5" y="424.3" fill="url('#html-build-reflection')"/>
<line x1="434.3" x2="434.3" y1="423.8" y2="424.2" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="431.7" y="470" class="itemlabel" text-anchor="middle" fill="black">
<tspan x="431.7">Css4j DOM</tspan> <tspan style="font-size: smaller; " x="431.7" dy="14.4">(own builder)</tspan>
</text>
<rect width="88.0" height="383" x="487.1" y="72" stroke="#ffffff" stroke-opacity="0.4" filter="url('#html-build-projection')"/>
<rect id="html-build-markBuildJsoup" width="88.0" height="383" x="487.1" y="72" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#b0d0d0"/>
<rect width="88.0" height="383" x="487.1" y="72" fill="url('#html-build-reflection')"/>
<line x1="535.9" x2="535.9" y1="67.4" y2="76.6" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="533.4" y="470" class="itemlabel" text-anchor="middle" fill="black">Jsoup</text>
<rect width="88.0" height="36.1" x="588.8" y="418.9" stroke="#ffffff" stroke-opacity="0.4" filter="url('#html-build-projection')"/>
<rect id="html-build-markBuildPlainJDK" width="88.0" height="36.1" x="588.8" y="418.9" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c0c061"/>
<rect width="88.0" height="36.1" x="588.8" y="418.9" fill="url('#html-build-reflection')"/>
<line x1="637.6" x2="637.6" y1="418.8" y2="419.2" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="635.1" y="470" class="itemlabel" text-anchor="middle" fill="black">JDK</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">4100</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">3280</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">2460</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">1640</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">820</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="html-build-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="html-build-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/html-build.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j-DOM4J</td><td class="number">340.34</td><td class="number">±11.21</td><td>ops/s</td></tr>
<tr><td>Css4j DOM</td><td class="number">324.86</td><td class="number">±2.16</td><td>ops/s</td></tr>
<tr><td>DOM4J</td><td class="number">327.60</td><td class="number">±2.21</td><td>ops/s</td></tr>
<tr><td>Css4j DOM (own builder)</td><td class="number">318.08</td><td class="number">±2.01</td><td>ops/s</td></tr>
<tr><td>Jsoup</td><td class="number">3,965.42</td><td class="number">±47.87</td><td>ops/s</td></tr>
<tr><td>JDK</td><td class="number">373.52</td><td class="number">±2.22</td><td>ops/s</td></tr>
</tbody></table>
<p>The standard DOM implementations are somewhat even in this test but Jsoup is much faster, about ten times the JDK and 12
times the speed of the others.</p>
</div>
<div class="tema" id="xml-build-small">
<h2>Build small XML documents</h2>
<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>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>XML build benchmark</title><defs>
<clipPath id="xml-build-small-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="xml-build-small-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="xml-build-small-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="xml-build-small-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#xml-build-small-caption {
font-size: 13pt;
font-weight: 700;
}
#xml-build-small-subcaption {
font-size: 9pt;
font-weight: 600;
}
#xml-build-small-x-title,#xml-build-small-y-title {
font-size: 10pt;
font-weight: 700;
}
.xml-build-small-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.xml-build-small-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#xml-build-small-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#xml-build-small-projection')" clip-path="url('#xml-build-small-cut-scale-shadow')"/>
<rect id="xml-build-small-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="xml-build-small-caption" x="355" y="22" text-anchor="middle" fill="black">XML build benchmark</text>
<text id="xml-build-small-subcaption" x="355" y="40" text-anchor="middle" fill="black">38kB file</text>
<rect width="108.0" height="355.6" x="80.6" y="99.4" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-small-projection')"/>
<rect id="xml-build-small-markBuildCss4jDOM4J" width="108.0" height="355.6" x="80.6" y="99.4" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c04d4d"/>
<rect width="108.0" height="355.6" x="80.6" y="99.4" fill="url('#xml-build-small-reflection')"/>
<line x1="139.2" x2="139.2" y1="85.5" y2="112.5" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="136.1" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j-DOM4J</text>
<rect width="108.0" height="362" x="202.6" y="93" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-small-projection')"/>
<rect id="xml-build-small-markBuildDOM" width="108.0" height="362" x="202.6" y="93" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="108.0" height="362" x="202.6" y="93" fill="url('#xml-build-small-reflection')"/>
<line x1="261.2" x2="261.2" y1="90.6" y2="95.4" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="258.1" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="108.0" height="379.2" x="324.6" y="75.8" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-small-projection')"/>
<rect id="xml-build-small-markBuildDOM4J" width="108.0" height="379.2" x="324.6" y="75.8" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#4d4dc0"/>
<rect width="108.0" height="379.2" x="324.6" y="75.8" fill="url('#xml-build-small-reflection')"/>
<line x1="383.2" x2="383.2" y1="64.4" y2="87.6" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="380.1" y="470" class="itemlabel" text-anchor="middle" fill="black">DOM4J</text>
<rect width="108.0" height="344.4" x="446.6" y="110.6" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-small-projection')"/>
<rect id="xml-build-small-markBuildJdk" width="108.0" height="344.4" x="446.6" y="110.6" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c04dc0"/>
<rect width="108.0" height="344.4" x="446.6" y="110.6" fill="url('#xml-build-small-reflection')"/>
<line x1="505.2" x2="505.2" y1="108.1" y2="113.9" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="502.1" y="470" class="itemlabel" text-anchor="middle" fill="black">
<tspan x="502.1">JDK</tspan> <tspan style="font-size: smaller; " x="502.1" dy="14.4">(css4j builder)</tspan>
</text>
<rect width="108.0" height="362.9" x="568.6" y="92.1" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-small-projection')"/>
<rect id="xml-build-small-markBuildPlainJdk" width="108.0" height="362.9" x="568.6" y="92.1" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c0c061"/>
<rect width="108.0" height="362.9" x="568.6" y="92.1" fill="url('#xml-build-small-reflection')"/>
<line x1="627.2" x2="627.2" y1="90.2" y2="93.8" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="624.1" y="470" class="itemlabel" text-anchor="middle" fill="black">JDK</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">550</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">440</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">330</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">220</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">110</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="xml-build-small-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="xml-build-small-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/xml-build-small.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j-DOM4J</td><td class="number">493.95</td><td class="number">±18.75</td><td>ops/s</td></tr>
<tr><td>Css4j DOM</td><td class="number">502.77</td><td class="number">±3.36</td><td>ops/s</td></tr>
<tr><td>DOM4J</td><td class="number">526.70</td><td class="number">±16.10</td><td>ops/s</td></tr>
<tr><td>JDK (css4j builder)</td><td class="number">478.38</td><td class="number">±4.05</td><td>ops/s</td></tr>
<tr><td>JDK</td><td class="number">504.02</td><td class="number">±2.49</td><td>ops/s</td></tr>
</tbody></table>
</div>
<div class="tema" id="xml-build">
<h2>Build XML documents</h2>
<p>The SAX parser that comes bundled with the JDK is used to parse and build a document (1MB file).</p>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>XML build benchmark</title><defs>
<clipPath id="xml-build-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="xml-build-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="xml-build-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="xml-build-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#xml-build-caption {
font-size: 13pt;
font-weight: 700;
}
#xml-build-subcaption {
font-size: 9pt;
font-weight: 600;
}
#xml-build-x-title,#xml-build-y-title {
font-size: 10pt;
font-weight: 700;
}
.xml-build-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.xml-build-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#xml-build-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#xml-build-projection')" clip-path="url('#xml-build-cut-scale-shadow')"/>
<rect id="xml-build-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="xml-build-caption" x="355" y="22" text-anchor="middle" fill="black">XML build benchmark</text>
<text id="xml-build-subcaption" x="355" y="40" text-anchor="middle" fill="black">1MB file</text>
<rect width="108.0" height="348.3" x="80.6" y="106.7" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-projection')"/>
<rect id="xml-build-markBuildCss4jDOM4J" width="108.0" height="348.3" x="80.6" y="106.7" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c04d4d"/>
<rect width="108.0" height="348.3" x="80.6" y="106.7" fill="url('#xml-build-reflection')"/>
<line x1="139.2" x2="139.2" y1="89.4" y2="124.6" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="136.1" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j-DOM4J</text>
<rect width="108.0" height="325.6" x="202.6" y="129.4" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-projection')"/>
<rect id="xml-build-markBuildDOM" width="108.0" height="325.6" x="202.6" y="129.4" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="108.0" height="325.6" x="202.6" y="129.4" fill="url('#xml-build-reflection')"/>
<line x1="261.2" x2="261.2" y1="126" y2="132" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="258.1" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="108.0" height="368.9" x="324.6" y="86.1" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-projection')"/>
<rect id="xml-build-markBuildDOM4J" width="108.0" height="368.9" x="324.6" y="86.1" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#4d4dc0"/>
<rect width="108.0" height="368.9" x="324.6" y="86.1" fill="url('#xml-build-reflection')"/>
<line x1="383.2" x2="383.2" y1="65.3" y2="106.7" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="380.1" y="470" class="itemlabel" text-anchor="middle" fill="black">DOM4J</text>
<rect width="108.0" height="265.3" x="446.6" y="189.7" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-projection')"/>
<rect id="xml-build-markBuildJdk" width="108.0" height="265.3" x="446.6" y="189.7" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c04dc0"/>
<rect width="108.0" height="265.3" x="446.6" y="189.7" fill="url('#xml-build-reflection')"/>
<line x1="505.2" x2="505.2" y1="185.4" y2="194.6" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="502.1" y="470" class="itemlabel" text-anchor="middle" fill="black">
<tspan x="502.1">JDK</tspan> <tspan style="font-size: smaller; " x="502.1" dy="14.4">(css4j builder)</tspan>
</text>
<rect width="108.0" height="357.7" x="568.6" y="97.3" stroke="#ffffff" stroke-opacity="0.4" filter="url('#xml-build-projection')"/>
<rect id="xml-build-markBuildPlainJdk" width="108.0" height="357.7" x="568.6" y="97.3" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c0c061"/>
<rect width="108.0" height="357.7" x="568.6" y="97.3" fill="url('#xml-build-reflection')"/>
<line x1="627.2" x2="627.2" y1="92.2" y2="101.8" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="624.1" y="470" class="itemlabel" text-anchor="middle" fill="black">JDK</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">111</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">89</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">67</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">44</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">22</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="xml-build-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="xml-build-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/xml-build.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j-DOM4J</td><td class="number">97.624</td><td class="number">±4.932</td><td>ops/s</td></tr>
<tr><td>Css4j DOM</td><td class="number">91.260</td><td class="number">±0.833</td><td>ops/s</td></tr>
<tr><td>DOM4J</td><td class="number">103.412</td><td class="number">±5.790</td><td>ops/s</td></tr>
<tr><td>JDK (css4j builder)</td><td class="number">74.366</td><td class="number">±1.288</td><td>ops/s</td></tr>
<tr><td>JDK</td><td class="number">100.270</td><td class="number">±1.335</td><td>ops/s</td></tr>
</tbody></table>
</div>
<div class="tema" id="traversal-next">
<h2>DOM traversal: <code>getFirstChild()/getNextSibling()</code></h2>
<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>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>DOM Traversal: NextSibling</title><defs>
<clipPath id="traversal-next-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="traversal-next-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="traversal-next-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="traversal-next-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#traversal-next-caption {
font-size: 13pt;
font-weight: 700;
}
#traversal-next-subcaption {
font-size: 9pt;
font-weight: 600;
}
#traversal-next-x-title,#traversal-next-y-title {
font-size: 10pt;
font-weight: 700;
}
.traversal-next-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.traversal-next-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#traversal-next-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#traversal-next-projection')" clip-path="url('#traversal-next-cut-scale-shadow')"/>
<rect id="traversal-next-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="traversal-next-caption" x="355" y="22" text-anchor="middle" fill="black">DOM Traversal: NextSibling</text>
<text id="traversal-next-subcaption" x="355" y="40" text-anchor="middle" fill="black">1MB file traversed by getFirstChild()/getNextSibling()</text>
<rect width="187.0" height="186.7" x="81.5" y="268.3" stroke="#ffffff" stroke-opacity="0.4" filter="url('#traversal-next-projection')"/>
<rect id="traversal-next-markTraverseDOM" width="187.0" height="186.7" x="81.5" y="268.3" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="187.0" height="186.7" x="81.5" y="268.3" fill="url('#traversal-next-reflection')"/>
<line x1="179.1" x2="179.1" y1="255.9" y2="280.1" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="174.1" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="187.0" height="12.5" x="284.9" y="442.5" stroke="#ffffff" stroke-opacity="0.4" filter="url('#traversal-next-projection')"/>
<rect id="traversal-next-markTraverseDOM4J" width="187.0" height="12.5" x="284.9" y="442.5" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c04d4d"/>
<rect width="187.0" height="12.5" x="284.9" y="442.5" fill="url('#traversal-next-reflection')"/>
<line x1="382.5" x2="382.5" y1="438.6" y2="445.4" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="377.4" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j-DOM4J</text>
<rect width="187.0" height="380.2" x="488.2" y="74.8" stroke="#ffffff" stroke-opacity="0.4" filter="url('#traversal-next-projection')"/>
<rect id="traversal-next-markTraverseJdk" width="187.0" height="380.2" x="488.2" y="74.8" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c0c061"/>
<rect width="187.0" height="380.2" x="488.2" y="74.8" fill="url('#traversal-next-reflection')"/>
<line x1="585.8" x2="585.8" y1="64.3" y2="85.7" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="580.7" y="470" class="itemlabel" text-anchor="middle" fill="black">JDK</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">6700</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">5360</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">4020</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">2680</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">1340</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="traversal-next-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="traversal-next-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/traversal-next.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j DOM</td><td class="number">3,159.4</td><td class="number">±204.6</td><td>ops/s</td></tr>
<tr><td>Css4j-DOM4J</td><td class="number">211.8</td><td class="number">±57.1</td><td>ops/s</td></tr>
<tr><td>JDK</td><td class="number">6,432.7</td><td class="number">±181.4</td><td>ops/s</td></tr>
</tbody></table>
<p><em>Note:</em> for unknown reasons, the usual procedure to build the JDK document with a <code>DocumentBuilderFactory</code> could not be used to initialize the document
traversed in the benchmark, as that document is somehow left in an inconsistent state with no child nodes; this happened with the initialization code being executed in a
<code>Scope.Benchmark</code> class and also when in a <code>static</code> initialization block. When that same code is executed in a JUnit test, the problem is not seen.</p>
<p>Because of this reason the JDK DOM document was built with css4j's <a href="https://css4j.github.io/api/latest/io.sf.carte.css4j/io/sf/carte/doc/dom/XMLDocumentBuilder.html"><code>XMLDocumentBuilder</code></a>,
although that process is not part of the timed benchmark.</p>
</div>
<div class="tema" id="traversal-prev">
<h2>DOM traversal: <code>getLastChild()/getPreviousSibling()</code></h2>
<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>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>DOM Traversal: PreviousSibling</title><defs>
<clipPath id="traversal-prev-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="traversal-prev-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="traversal-prev-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="traversal-prev-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#traversal-prev-caption {
font-size: 13pt;
font-weight: 700;
}
#traversal-prev-subcaption {
font-size: 9pt;
font-weight: 600;
}
#traversal-prev-x-title,#traversal-prev-y-title {
font-size: 10pt;
font-weight: 700;
}
.traversal-prev-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.traversal-prev-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#traversal-prev-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#traversal-prev-projection')" clip-path="url('#traversal-prev-cut-scale-shadow')"/>
<rect id="traversal-prev-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="traversal-prev-caption" x="355" y="22" text-anchor="middle" fill="black">DOM Traversal: PreviousSibling</text>
<text id="traversal-prev-subcaption" x="355" y="40" text-anchor="middle" fill="black">1MB file traversed by getLastChild()/getPreviousSibling()</text>
<rect width="187.0" height="145.1" x="81.5" y="309.9" stroke="#ffffff" stroke-opacity="0.4" filter="url('#traversal-prev-projection')"/>
<rect id="traversal-prev-markTraversePrevDOM" width="187.0" height="145.1" x="81.5" y="309.9" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="187.0" height="145.1" x="81.5" y="309.9" fill="url('#traversal-prev-reflection')"/>
<line x1="179.1" x2="179.1" y1="293.5" y2="326.5" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="174.1" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="187.0" height="8.6" x="284.9" y="446.4" stroke="#ffffff" stroke-opacity="0.4" filter="url('#traversal-prev-projection')"/>
<rect id="traversal-prev-markTraversePrevDOM4J" width="187.0" height="8.6" x="284.9" y="446.4" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c04d4d"/>
<rect width="187.0" height="8.6" x="284.9" y="446.4" fill="url('#traversal-prev-reflection')"/>
<line x1="382.5" x2="382.5" y1="445.3" y2="446.7" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="377.4" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j-DOM4J</text>
<rect width="187.0" height="379.1" x="488.2" y="75.9" stroke="#ffffff" stroke-opacity="0.4" filter="url('#traversal-prev-projection')"/>
<rect id="traversal-prev-markTraversePrevJdk" width="187.0" height="379.1" x="488.2" y="75.9" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c0c061"/>
<rect width="187.0" height="379.1" x="488.2" y="75.9" fill="url('#traversal-prev-reflection')"/>
<line x1="585.8" x2="585.8" y1="66.5" y2="85.5" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="580.7" y="470" class="itemlabel" text-anchor="middle" fill="black">JDK</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">7500</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">6000</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">4500</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">3000</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">1500</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="traversal-prev-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="traversal-prev-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/traversal-prev.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j DOM</td><td class="number">2,748.7</td><td class="number">±312.8</td><td>ops/s</td></tr>
<tr><td>Css4j-DOM4J</td><td class="number">163.0</td><td class="number">±12.7</td><td>ops/s</td></tr>
<tr><td>JDK</td><td class="number">7,179.1</td><td class="number">±179.9</td><td>ops/s</td></tr>
</tbody></table>
<p>The Css4j-DOM4J results are representative for DOM4J as well.</p>
</div>
<div class="tema" id="nodeiterator-small">
<h2>DOM traversal: <code>NodeIterator</code> (small file)</h2>
<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>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>DOM Traversal: NodeIterator (small file)</title><defs>
<clipPath id="nodeiterator-small-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="nodeiterator-small-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="nodeiterator-small-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="nodeiterator-small-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#nodeiterator-small-caption {
font-size: 13pt;
font-weight: 700;
}
#nodeiterator-small-subcaption {
font-size: 9pt;
font-weight: 600;
}
#nodeiterator-small-x-title,#nodeiterator-small-y-title {
font-size: 10pt;
font-weight: 700;
}
.nodeiterator-small-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.nodeiterator-small-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#nodeiterator-small-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#nodeiterator-small-projection')" clip-path="url('#nodeiterator-small-cut-scale-shadow')"/>
<rect id="nodeiterator-small-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="nodeiterator-small-caption" x="355" y="22" text-anchor="middle" fill="black">DOM Traversal: NodeIterator (small file)</text>
<text id="nodeiterator-small-subcaption" x="355" y="40" text-anchor="middle" fill="black">38kB file traversed by NodeIterator</text>
<rect width="285.0" height="384.7" x="83" y="70.3" stroke="#ffffff" stroke-opacity="0.4" filter="url('#nodeiterator-small-projection')"/>
<rect id="nodeiterator-small-markNodeIteratorDOM" width="285.0" height="384.7" x="83" y="70.3" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="285.0" height="384.7" x="83" y="70.3" fill="url('#nodeiterator-small-reflection')"/>
<line x1="229.4" x2="229.4" y1="65.5" y2="74.5" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="221.8" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="285.0" height="278" x="388" y="177" stroke="#ffffff" stroke-opacity="0.4" filter="url('#nodeiterator-small-projection')"/>
<rect id="nodeiterator-small-markNodeIteratorJdk" width="285.0" height="278" x="388" y="177" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c0c061"/>
<rect width="285.0" height="278" x="388" y="177" fill="url('#nodeiterator-small-reflection')"/>
<line x1="534.4" x2="534.4" y1="171.6" y2="182.4" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="526.8" y="470" class="itemlabel" text-anchor="middle" fill="black">JDK</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">118000</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">94400</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">70800</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">47200</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">23600</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="nodeiterator-small-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="nodeiterator-small-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/nodeiterator-small.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j DOM</td><td class="number">114,626</td><td class="number">±1,354</td><td>ops/s</td></tr>
<tr><td>JDK</td><td class="number">82,837</td><td class="number">±1,624</td><td>ops/s</td></tr>
</tbody></table>
<p>DOM4J and Jsoup are not included as they lack a <code>NodeIterator</code>.</p>
</div>
<div class="tema" id="nodeiterator">
<h2>DOM traversal: <code>NodeIterator</code></h2>
<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>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>DOM Traversal: NodeIterator</title><defs>
<clipPath id="nodeiterator-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="nodeiterator-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="nodeiterator-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="nodeiterator-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#nodeiterator-caption {
font-size: 13pt;
font-weight: 700;
}
#nodeiterator-subcaption {
font-size: 9pt;
font-weight: 600;
}
#nodeiterator-x-title,#nodeiterator-y-title {
font-size: 10pt;
font-weight: 700;
}
.nodeiterator-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.nodeiterator-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#nodeiterator-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#nodeiterator-projection')" clip-path="url('#nodeiterator-cut-scale-shadow')"/>
<rect id="nodeiterator-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="nodeiterator-caption" x="355" y="22" text-anchor="middle" fill="black">DOM Traversal: NodeIterator</text>
<text id="nodeiterator-subcaption" x="355" y="40" text-anchor="middle" fill="black">1MB file traversed by NodeIterator</text>
<rect width="285.0" height="186.5" x="83" y="268.5" stroke="#ffffff" stroke-opacity="0.4" filter="url('#nodeiterator-projection')"/>
<rect id="nodeiterator-markNodeIteratorDOM" width="285.0" height="186.5" x="83" y="268.5" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="285.0" height="186.5" x="83" y="268.5" fill="url('#nodeiterator-reflection')"/>
<line x1="229.4" x2="229.4" y1="264.6" y2="271.4" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="221.8" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="285.0" height="372.9" x="388" y="82.1" stroke="#ffffff" stroke-opacity="0.4" filter="url('#nodeiterator-projection')"/>
<rect id="nodeiterator-markNodeIteratorJdk" width="285.0" height="372.9" x="388" y="82.1" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c0c061"/>
<rect width="285.0" height="372.9" x="388" y="82.1" fill="url('#nodeiterator-reflection')"/>
<line x1="534.4" x2="534.4" y1="70.1" y2="93.9" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="526.8" y="470" class="itemlabel" text-anchor="middle" fill="black">JDK</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">4700</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">3760</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">2820</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">1880</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">940</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="nodeiterator-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="nodeiterator-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/nodeiterator.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j DOM</td><td class="number">2,214.1</td><td class="number">±39.9</td><td>ops/s</td></tr>
<tr><td>JDK</td><td class="number">4,425.9</td><td class="number">±141.5</td><td>ops/s</td></tr>
</tbody></table>
<p>DOM4J is not included as it lacks a <code>NodeIterator</code>.</p>
<p><em>Note:</em> sometimes the <code>NodeIterator</code> created by the JDK is in an inconsistent state, and fails with an exception like:</p>
<pre class="code"># Warmup Iteration 1: <failure>
java.lang.ArrayIndexOutOfBoundsException: Index 34 out of bounds for length 33
at java.base/java.util.ArrayList.add(ArrayList.java:455)
at java.base/java.util.ArrayList.add(ArrayList.java:467)
at java.xml/com.sun.org.apache.xerces.internal.dom.DocumentImpl.createNodeIterator(DocumentImpl.java:255)
at io.sf.carte.mark.dom.DOMIteratorMark.markNodeIteratorJdk(DOMIteratorMark.java:46)
</failure></pre>
<p>But I have observed this only while benchmarking, and not in other cases.</p>
</div>
<div class="tema" id="treewalker-small">
<h2>DOM traversal: <code>TreeWalker</code> (small file)</h2>
<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>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>DOM Traversal: TreeWalker (small file)</title><defs>
<clipPath id="treewalker-small-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="treewalker-small-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="treewalker-small-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="treewalker-small-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#treewalker-small-caption {
font-size: 13pt;
font-weight: 700;
}
#treewalker-small-subcaption {
font-size: 9pt;
font-weight: 600;
}
#treewalker-small-x-title,#treewalker-small-y-title {
font-size: 10pt;
font-weight: 700;
}
.treewalker-small-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.treewalker-small-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#treewalker-small-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#treewalker-small-projection')" clip-path="url('#treewalker-small-cut-scale-shadow')"/>
<rect id="treewalker-small-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="treewalker-small-caption" x="355" y="22" text-anchor="middle" fill="black">DOM Traversal: TreeWalker (small file)</text>
<text id="treewalker-small-subcaption" x="355" y="40" text-anchor="middle" fill="black">38kB file traversed by TreeWalker</text>
<rect width="285.0" height="205.2" x="83" y="249.8" stroke="#ffffff" stroke-opacity="0.4" filter="url('#treewalker-small-projection')"/>
<rect id="treewalker-small-markTreeWalkerDOM" width="285.0" height="205.2" x="83" y="249.8" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="285.0" height="205.2" x="83" y="249.8" fill="url('#treewalker-small-reflection')"/>
<line x1="229.4" x2="229.4" y1="248.2" y2="251.8" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="221.8" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="285.0" height="356.3" x="388" y="98.7" stroke="#ffffff" stroke-opacity="0.4" filter="url('#treewalker-small-projection')"/>
<rect id="treewalker-small-markTreeWalkerJdk" width="285.0" height="356.3" x="388" y="98.7" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c0c061"/>
<rect width="285.0" height="356.3" x="388" y="98.7" fill="url('#treewalker-small-reflection')"/>
<line x1="534.4" x2="534.4" y1="64.5" y2="133.5" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="526.8" y="470" class="itemlabel" text-anchor="middle" fill="black">JDK</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">109000</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">87200</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">65400</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">43600</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">21800</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="treewalker-small-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="treewalker-small-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/treewalker-small.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j DOM</td><td class="number">56,486</td><td class="number">±487</td><td>ops/s</td></tr>
<tr><td>JDK</td><td class="number">98,074</td><td class="number">±9,500</td><td>ops/s</td></tr>
</tbody></table>
<p>Neither DOM4J nor Jsoup provide a <code>TreeWalker</code>.</p>
</div>
<div class="tema" id="treewalker">
<h2>DOM traversal: <code>TreeWalker</code></h2>
<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>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>DOM Traversal: TreeWalker</title><defs>
<clipPath id="treewalker-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="treewalker-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="treewalker-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="treewalker-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#treewalker-caption {
font-size: 13pt;
font-weight: 700;
}
#treewalker-subcaption {
font-size: 9pt;
font-weight: 600;
}
#treewalker-x-title,#treewalker-y-title {
font-size: 10pt;
font-weight: 700;
}
.treewalker-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.treewalker-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#treewalker-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#treewalker-projection')" clip-path="url('#treewalker-cut-scale-shadow')"/>
<rect id="treewalker-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="treewalker-caption" x="355" y="22" text-anchor="middle" fill="black">DOM Traversal: TreeWalker</text>
<text id="treewalker-subcaption" x="355" y="40" text-anchor="middle" fill="black">1MB file traversed by TreeWalker</text>
<rect width="285.0" height="179.1" x="83" y="275.9" stroke="#ffffff" stroke-opacity="0.4" filter="url('#treewalker-projection')"/>
<rect id="treewalker-markTreeWalkerDOM" width="285.0" height="179.1" x="83" y="275.9" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="285.0" height="179.1" x="83" y="275.9" fill="url('#treewalker-reflection')"/>
<line x1="229.4" x2="229.4" y1="272.9" y2="279.1" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="221.8" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="285.0" height="376.1" x="388" y="78.9" stroke="#ffffff" stroke-opacity="0.4" filter="url('#treewalker-projection')"/>
<rect id="treewalker-markTreeWalkerJdk" width="285.0" height="376.1" x="388" y="78.9" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#c0c061"/>
<rect width="285.0" height="376.1" x="388" y="78.9" fill="url('#treewalker-reflection')"/>
<line x1="534.4" x2="534.4" y1="63.9" y2="94.1" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="526.8" y="470" class="itemlabel" text-anchor="middle" fill="black">JDK</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">4800</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">3840</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">2880</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">1920</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">960</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="treewalker-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="treewalker-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/treewalker.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j DOM</td><td class="number">2,170.8</td><td class="number">±37.8</td><td>ops/s</td></tr>
<tr><td>JDK</td><td class="number">4,558.8</td><td class="number">±183.0</td><td>ops/s</td></tr>
</tbody></table>
<p>As mentioned, neither DOM4J nor Jsoup provide a <code>TreeWalker</code>.</p>
</div>
<div class="tema" id="iterator-small">
<h2>DOM traversal: <code>iterator()</code> (small file)</h2>
<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>,
DOM4J's <a href="https://dom4j.github.io/javadoc/2.1.3/org/dom4j/Branch.html#nodeIterator--"><code>nodeIterator()</code></a> and Jsoup's
iterable <a href="https://jsoup.org/apidocs/org/jsoup/nodes/Node.html#childNodes()"><code>childNodes()</code></a>.</p>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>DOM Traversal: child node iterators (small file)</title><defs>
<clipPath id="iterator-small-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="iterator-small-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="iterator-small-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="iterator-small-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#iterator-small-caption {
font-size: 13pt;
font-weight: 700;
}
#iterator-small-subcaption {
font-size: 9pt;
font-weight: 600;
}
#iterator-small-x-title,#iterator-small-y-title {
font-size: 10pt;
font-weight: 700;
}
.iterator-small-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.iterator-small-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#iterator-small-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#iterator-small-projection')" clip-path="url('#iterator-small-cut-scale-shadow')"/>
<rect id="iterator-small-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="iterator-small-caption" x="355" y="22" text-anchor="middle" fill="black">DOM Traversal: child node iterators (small file)</text>
<text id="iterator-small-subcaption" x="355" y="40" text-anchor="middle" fill="black">38kB file traversed by child iterators</text>
<rect width="187.0" height="386.4" x="81.5" y="68.6" stroke="#ffffff" stroke-opacity="0.4" filter="url('#iterator-small-projection')"/>
<rect id="iterator-small-markIteratorDOM" width="187.0" height="386.4" x="81.5" y="68.6" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="187.0" height="386.4" x="81.5" y="68.6" fill="url('#iterator-small-reflection')"/>
<line x1="179.1" x2="179.1" y1="64.6" y2="73.4" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="174.1" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="187.0" height="60" x="284.9" y="395" stroke="#ffffff" stroke-opacity="0.4" filter="url('#iterator-small-projection')"/>
<rect id="iterator-small-markIteratorDOM4J" width="187.0" height="60" x="284.9" y="395" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#4d4dc0"/>
<rect width="187.0" height="60" x="284.9" y="395" fill="url('#iterator-small-reflection')"/>
<line x1="382.5" x2="382.5" y1="394.7" y2="395.3" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="377.4" y="470" class="itemlabel" text-anchor="middle" fill="black">DOM4J</text>
<rect width="187.0" height="350.5" x="488.2" y="104.5" stroke="#ffffff" stroke-opacity="0.4" filter="url('#iterator-small-projection')"/>
<rect id="iterator-small-markIteratorJsoup" width="187.0" height="350.5" x="488.2" y="104.5" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#b0d0d0"/>
<rect width="187.0" height="350.5" x="488.2" y="104.5" fill="url('#iterator-small-reflection')"/>
<line x1="585.8" x2="585.8" y1="99.7" y2="108.3" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="580.7" y="470" class="itemlabel" text-anchor="middle" fill="black">Jsoup</text>
<text x="74" y="59" class="scaleitem" text-anchor="end">114000</text>
<text x="74" y="139" class="scaleitem" text-anchor="end">91200</text>
<text x="74" y="219" class="scaleitem" text-anchor="end">68400</text>
<text x="74" y="299" class="scaleitem" text-anchor="end">45600</text>
<text x="74" y="379" class="scaleitem" text-anchor="end">22800</text>
<text x="74" y="459" class="scaleitem" text-anchor="end">0</text>
<text id="iterator-small-y-title" x="16" y="260" text-anchor="middle" fill="black" transform="rotate(270,16,260)">Throughput (ops/s)</text>
<text id="iterator-small-x-title" x="350" y="496" text-anchor="middle" fill="black">DOM Implementation</text>
<image src="benchmark/iterator-small.png" xlink:href=""/></svg>
<p>Numeric results (higher is better):</p>
<table class="normaltbl carteitem">
<thead><tr><th>Implementation</th><th>Score</th><th>Error</th><th>Unit</th></tr></thead><tbody>
<tr><td>Css4j DOM</td><td class="number">111,245.8</td><td class="number">±1,274.0</td><td>ops/s</td></tr>
<tr><td>DOM4J</td><td class="number">17,267.2</td><td class="number">±82.7</td><td>ops/s</td></tr>
<tr><td>Jsoup</td><td class="number">100,902.9</td><td class="number">±1,250.8</td><td>ops/s</td></tr>
</tbody></table>
<p>The JDK's DOM provides no iterable child collections.</p>
</div>
<div class="tema" id="iterator">
<h2>DOM traversal: <code>iterator()</code></h2>
<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>
and DOM4J's <a href="https://dom4j.github.io/javadoc/2.1.3/org/dom4j/Branch.html#nodeIterator--"><code>nodeIterator()</code></a>.</p>
<svg version="1.1" baseprofile="full" xmlns="http://www.w3.org/2000/svg" width="700" height="500" viewbox="0 0 700 500" class="carteitem">
<title>DOM Traversal: child node iterators</title><defs>
<clipPath id="iterator-cut-scale-shadow">
<rect width="623" height="15" x="71" y="41"/>
<rect width="8" height="418" x="685" y="37"/>
</clipPath>
<linearGradient id="iterator-background" gradientunits="objectBoundingBox" x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#cde1ff" offset="0"/>
<stop stop-color="#ffffff" offset="0.9"/>
</linearGradient>
<linearGradient id="iterator-reflection" gradientunits="objectBoundingBox" x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#eeeeee" offset="0" stop-opacity="0.4"/>
<stop stop-color="#ffffff" offset="0.75" stop-opacity="0"/>
</linearGradient>
<filter id="iterator-projection" filterunits="objectBoundingBox" x="0" y="-0.1" width="1.2" height="1.2">
<feGaussianBlur in="SourceAlpha" stddeviation="2" result="alpha_blur"/>
<feOffset in="alpha_blur" dx="3" dy="-3" result="offset_alpha_blur"/>
</filter>
</defs>
<style>text {
font-family: "Open Sans", Verdana, sans-serif;
}
#iterator-caption {
font-size: 13pt;
font-weight: 700;
}
#iterator-subcaption {
font-size: 9pt;
font-weight: 600;
}
#iterator-x-title,#iterator-y-title {
font-size: 10pt;
font-weight: 700;
}
.iterator-itemlabel {
font-size: 9pt;
font-weight: 400;
}
.iterator-scaleItem {
font-size: 9pt;
font-weight: 300;
}
</style>
<rect width="100%" height="100%" fill="url('#iterator-background')"/>
<rect width="610" height="400" x="75" y="55" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0" filter="url('#iterator-projection')" clip-path="url('#iterator-cut-scale-shadow')"/>
<rect id="iterator-chartbox" width="610" height="400" x="75" y="55" stroke-width="1" stroke="#000000" fill="rgb(0,0,0)" fill-opacity="0"/>
<text id="iterator-caption" x="355" y="22" text-anchor="middle" fill="black">DOM Traversal: child node iterators</text>
<text id="iterator-subcaption" x="355" y="40" text-anchor="middle" fill="black">1MB file traversed by child iterators</text>
<rect width="285.0" height="367.7" x="83" y="87.3" stroke="#ffffff" stroke-opacity="0.4" filter="url('#iterator-projection')"/>
<rect id="iterator-markIteratorDOM" width="285.0" height="367.7" x="83" y="87.3" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#61c061"/>
<rect width="285.0" height="367.7" x="83" y="87.3" fill="url('#iterator-reflection')"/>
<line x1="229.4" x2="229.4" y1="63" y2="111" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>
<text x="221.8" y="470" class="itemlabel" text-anchor="middle" fill="black">Css4j DOM</text>
<rect width="285.0" height="94.1" x="388" y="360.9" stroke="#ffffff" stroke-opacity="0.4" filter="url('#iterator-projection')"/>
<rect id="iterator-markIteratorDOM4J" width="285.0" height="94.1" x="388" y="360.9" stroke="black" stroke-width="0.4" stroke-opacity="0.3" fill="#4d4dc0"/>
<rect width="285.0" height="94.1" x="388" y="360.9" fill="url('#iterator-reflection')"/>
<line x1="534.4" x2="534.4" y1="358.3" y2="363.7" stroke="#888888" stroke-opacity="0.867" stroke-width="5" stroke-linecap="round" stroke-dasharray="1" class="errorbar"/>