-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbenchmarks.html
391 lines (356 loc) · 16.2 KB
/
benchmarks.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Copyright (C) 2005, 2006 Joe Walnes.
Copyright (C) 2006, 2007, 2008, 2021 XStream committers.
All rights reserved.
The software in this package is published under the terms of the BSD
style license a copy of which has been included with this distribution in
the LICENSE.txt file.
Created on 29. January 2005 by Joe Walnes
-->
<head>
<title>XStream - Benchmarks</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<style type="text/css">
#content td { text-align: right;}
#content dt { font-weight: bold;}
</style>
<!-- Google analytics -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-110973-2";
urchinTracker();
</script>
</head>
<body>
<div id="banner">
<a href="index.html"><img id="logo" src="logo.gif" alt="XStream"/></a>
</div>
<div id="center" class="Content2Column"> <!-- Content3Column for index -->
<div id="content">
<h1 class="FirstChild">Benchmarks</h1>
<h2 id="introduction">Introduction</h2>
<p>Benchmark results are always dependent on a very individual setup. Normally it is not useful to generalize such results
for every use case, but it can give you a hint. However, if you're really in the need of maximum performance, you should
probably create an own benchmark with your objects or even use a profiler to detect the real hot spots in your application.</p>
<p>XStream uses the Java Microbenchmark Harness (<a href="http://openjdk.java.net/projects/code-tools/jmh/">JMH</a>)
of the JDK Tools as benchmark framework starting with version 1.4.9. As result it contains a ZIP file
(xstream-jmh-<version>-app.zip) as new artifact containing anything required to run the benchmarks. Unpack the file
and use the scripts in the <em>bin</em> directory to execute the benchmarks. Use option -h to look at the options provided
by JMH. You may exchange the libraries in the <em>lib</em> directory with other versions of XStream or the individual
parsers or you may even add new JMH benchmarks to the default ones of XStream.</p>
<p>All benchmark values below measure the average throughput in nanosecond per operation. JMH provides additional
measurement options, see online help. The maximum deviation for each benchmark is recorded in the reference files of the
distributed ZIP file. The benchmark is executed on Linux 6.6.52 Gentoo 64-bit system with an Intel Core i7 CPU 14700K
using OpenJDK 17.0.13. Note again, that these values are no replacement for real profiler results and they may vary
from run to run (see reference files) due to this machine's background processes. However, it can give you some idea of
what you can expect using different parser technologies.</p>
<h2 id="parser">Parser Benchmark</h2>
<p>The values represent the average throughput of 15 runs with a single thread. The benchmarks emphasis the parser
efficiency for different structures.</p>
<table summary="Benchmark for all parsers supported by XStream using different object structures">
<tr>
<th>Parser</th>
<th>Text</th>
<th>Array</th>
<th>Nested</th>
</tr>
<tr>
<th>W3C DOM (Open JDK 17.0.13)</th>
<td>2316834.389</td>
<td>254288.386</td>
<td>1207325.529</td>
</tr>
<tr>
<th>JDOM (1.1.3)</th>
<td>1429464.817</td>
<td>1054291.413</td>
<td>3136911.743</td>
</tr>
<tr>
<th>JDOM 2 (2.0.5)</th>
<td>1324056.096</td>
<td>2259612.310</td>
<td>2779012.689</td>
</tr>
<tr>
<th>DOM4J (1.6.1)</th>
<td>2281134.406</td>
<td>43258468.546</td>
<td>1356678.442</td>
</tr>
<tr>
<th>XOM (1.1)</th>
<td>1867044.534</td>
<td>5679751.225</td>
<td>1308598.865</td>
</tr>
<tr>
<th>StAX (BEA 1.2.0)</th>
<td>632376.873</td>
<td>128796.847</td>
<td>140502.528</td>
</tr>
<tr>
<th>StAX (Woodstox 5.0.4)</th>
<td>419207.440</td>
<td>129315.380</td>
<td>126914.212</td>
</tr>
<tr>
<th>StAX (Open JDK 17.0.13)</th>
<td>1859924.150</td>
<td>141843.352</td>
<td>145046.544</td>
</tr>
<tr>
<th>XPP (MXParser 1.2.2)</th>
<td>433709.439</td>
<td>140599.267</td>
<td>12616894.304</td>
</tr>
<tr>
<th>XPP (Xpp3 min 1.1.4c)</th>
<td>478171.526</td>
<td>154366.191</td>
<td>2123961.431</td>
</tr>
<tr>
<th>XPP (kXML2 min 2.3.0)</th>
<td>730153.987</td>
<td>180229.565</td>
<td>7118388.750</td>
</tr>
<tr>
<th>Binary (XStream 1.4.21)</th>
<td>284528.119</td>
<td>138862.326</td>
<td>101430.955</td>
</tr>
<tr>
<th>Jettison (1.5.4)</th>
<td>685921.130</td>
<td>121462.883</td>
<td>153003.086</td>
</tr>
</table>
<dl>
<dt>Text</dt>
<dd>A single element with a text of 100.000 characters.</dd>
<dt>Array</dt>
<dd>A single element with 1.000 child elements.</dd>
<dt>Nested</dt>
<dd>Nested elements in 1000 levels (since version 1.4.10).</dd>
</dl>
<h2 id="converterType">Converter Type Benchmark</h2>
<p>The values represent the average throughput of 16 runs with four threads using the Xpp3 parser for a structure
with 1.000 elements. The benchmarks demonstrate the different converter types that can be used for a standard Java
class.</p>
<table summary="Benchmark for different converter types of XStream">
<tr>
<th>Converter Type</th>
<th>Throughput</th>
</tr>
<tr>
<th>Custom</th>
<td>1701927.802</td>
</tr>
<tr>
<th>Java Bean</th>
<td>3776166.839</td>
</tr>
<tr>
<th>Reflection</th>
<td>4212308.005</td>
</tr>
</table>
<dl>
<dt>Custom</dt>
<dd>A converter especially written for the Java type to convert.</dd>
<dt>Java Bean</dt>
<dd>Usage of the generic JavaBeanConverter, since the Java type respects the Java Bean contract.</dd>
<dt>Reflection</dt>
<dd>Usage of the generic converter based on reflection.</dd>
</dl>
<h2 id="stringConverter">String Converter Benchmark</h2>
<p>The values represent the average throughput of 16 runs with four threads using the Xpp3 parser for a structure
with 10.000 string elements of various sizes and duplicates. The benchmarks demonstrate different implementations
and configurations of the StringConverter.</p>
<table summary="Benchmark for different StringConverter strategies">
<tr>
<th>StringConverter Strategy</th>
<th>Throughput</th>
</tr>
<tr>
<th>No Cache</th>
<td>2417842.610</td>
</tr>
<tr>
<th>Intern</th>
<td>3148497.871</td>
</tr>
<tr>
<th>ConcurrentMap (length limit)</th>
<td>2911799.476</td>
</tr>
<tr>
<th>ConcurrentMap (unlimited)</th>
<td>3117778.159</td>
</tr>
<tr>
<th>Sync'd WeakCache (length limit)</th>
<td>2886518.868</td>
</tr>
<tr>
<th>Sync'd WeakCache (unlimited)</th>
<td>3287897.285</td>
</tr>
</table>
<dl>
<dt>No Cache</dt>
<dd>An implementation that does not cache deserialized String values with the consequence that repeated values
will always allocate separate memory.</dd>
<dt>Intern</dt>
<dd>An implementation that uses String.intern() to cache the individual values. The memory pool used for the
values is dependent on the JDK version. Up to Java 7 this was the permanent generation space i.e. the memory has
to be shared with all loaded classes. It is up to the garbage collection when these string values are freed
again.</dd>
<dt>ConcurrentMap (length limit)</dt>
<dd>An implementation that uses a ConcurrentHashMap as cache for strings of limited length (38 characters). The
lifetime of the cache is equivalent with the lifetime of the XStream instance.</dd>
<dt>ConcurrentMap (unlimited)</dt>
<dd>An implementation that uses a ConcurrentHashMap as cache for all strings. The lifetime of the cache is
equivalent with the lifetime of the XStream instance.</dd>
<dt>Sync'd WeakCache (length limit)</dt>
<dd>An implementation that uses a WeakCache for strings of limited length (38 characters). This cache uses weak
references for its keys and values. An entry is therefore only kept as long as the deserialized object structure
is referencing it. This is XStream's default strategy.</dd>
<dt>Syn'd WeakCache (unlimited)</dt>
<dd>An implementation that uses a WeakCache for all strings. This cache uses weak references for its keys and
values. An entry is therefore ony kept as long as the deserialized object structure is referencing it.</dd>
</dl>
<h2 id="nameCoder">Name Coder Benchmark</h2>
<p>The values represent the average throughput of 25 runs with four threads using the Xpp3 parser for a structure
with 250 nested elements using names invalid for XML elements. The benchmarks demonstrate different implementation
strategies for a NameCoder to create valid tag names in XML.</p>
<table summary="Benchmark for different NameCoder strategies">
<tr>
<th>NameCoder Implementation</th>
<th>Throughput</th>
</tr>
<tr>
<th>No Coding</th>
<td>1678462.527</td>
</tr>
<tr>
<th>Dollar Coding</th>
<td>1267352.602</td>
</tr>
<tr>
<th>Escaped Underscore Coding</th>
<td>1486767.570</td>
</tr>
<tr>
<th>Cached Escaped Underscore Coding</th>
<td>1363975.538</td>
</tr>
<tr>
<th>XML Friendly Coding</th>
<td>1404702.393</td>
</tr>
</table>
<dl>
<dt>No Coding</dt>
<dd>An implementation that does not encode the names of XML elements. It relies on the fact that the object graph
does not contain elements with invalid XML names, because the name of the class types and members are either
conforming or have been aliased.</dd>
<dt>Dollar Coding</dt>
<dd>An implementation that uses String.replace to replace any dollar sign with '·' (middle dot), a valid
character normally not used for Java identifiers. In typical Java code there are no other invalid characters used
for Java identifiers, however, Java allows identifiers to contain a wide range of UTF-8 characters and the JVM
has even less restrictions.</dd>
<dt>Escaped Underscore Coding</dt>
<dd>An implementation that uses a StringBuilder to create the XML name by replacing any dollar sign with '_-' and
escapes every plain underscore with two ones. The implementation will therefore only use characters in the
standard ASCII range. It is not possible to use a simple minus sign as replacement because it is not a valid
first character for XML names. However, the comments about Java identifiers and JVM identifiers from the Dollar
Coding still apply.</dd>
<dt>Cached Escaped Underscore Coding</dt>
<dd>An implementation that implements a cache for the NameCoder that escapes the underscores.</dd>
<dt>XML Friendly Coding</dt>
<dd>The default implementation of XStream using a StringBuilder and a cache, encoding any character that is
invalid for XML names. It implements also the underscore escaping for compatibility reasons with XML created by
earlier versions of XStream.</dd>
</dl>
<br/>
</div>
</div>
<div class="SidePanel" id="left">
<div class="MenuGroup">
<h1>Software</h1>
<ul>
<li><a href="index.html">About XStream</a></li>
<li><a href="news.html">News</a></li>
<li><a href="changes.html">Change History</a></li>
<li><a href="security.html">Security Aspects</a></li>
<li><a href="versioning.html">About Versioning</a></li>
</ul>
</div>
<div class="MenuGroup">
<h1>Evaluating XStream</h1>
<ul>
<li><a href="tutorial.html">Two Minute Tutorial</a></li>
<li><a href="license.html">License</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="references.html">References</a></li>
<li class="currentLink">Benchmarks</li>
<li><a href="https://www.openhub.net/p/xstream">Code Statistics</a></li>
</ul>
</div>
<div class="MenuGroup">
<h1>Using XStream</h1>
<ul>
<li><a href="architecture.html">Architecture Overview</a></li>
<li><a href="graphs.html">Object references</a></li>
<li><a href="manual-tweaking-output.html">Tweaking the Output</a></li>
<li><a href="converters.html">Converters</a></li>
<li><a href="faq.html">Frequently Asked Questions</a></li>
<li><a href="mailing-lists.html">Mailing Lists</a></li>
<li><a href="issues.html">Reporting Issues</a></li>
</ul>
</div>
<div class="MenuGroup">
<h1>Javadoc</h1>
<ul>
<li><a href="javadoc/index.html">XStream Core</a></li>
<li><a href="hibernate-javadoc/index.html">Hibernate Extensions</a></li>
<li><a href="jmh-javadoc/index.html">JMH Module</a></li>
</ul>
</div>
<div class="MenuGroup">
<h1>Tutorials</h1>
<ul>
<li><a href="tutorial.html">Two Minute Tutorial</a></li>
<li><a href="alias-tutorial.html">Alias Tutorial</a></li>
<li><a href="annotations-tutorial.html">Annotations Tutorial</a></li>
<li><a href="converter-tutorial.html">Converter Tutorial</a></li>
<li><a href="objectstream.html">Object Streams Tutorial</a></li>
<li><a href="persistence-tutorial.html">Persistence API Tutorial</a></li>
<li><a href="json-tutorial.html">JSON Tutorial</a></li>
<li><a href="http://www.studytrails.com/java/xml/xstream/xstream-introduction.jsp">StudyTrails</a></li>
</ul>
</div>
<div class="MenuGroup">
<h1>Developing XStream</h1>
<ul>
<li><a href="how-to-contribute.html">How to Contribute</a></li>
<li><a href="team.html">Development Team</a></li>
<li><a href="repository.html">Source Repository</a></li>
<li><a href="https://travis-ci.org/x-stream/xstream/branches">Continuous Integration</a></li>
</ul>
</div>
</div>
</body>
</html>