1ffe3c632Sopenharmony_ci# Protobuf Performance
2ffe3c632Sopenharmony_ciThe following benchmark test results were produced on a workstation utilizing an Intel® Xeon® Processor E5-2630 with 32GB of RAM.
3ffe3c632Sopenharmony_ci
4ffe3c632Sopenharmony_ciThis table contains the results of three separate languages:
5ffe3c632Sopenharmony_ci
6ffe3c632Sopenharmony_ci* **C++** - For C++, there are three parsing methods:
7ffe3c632Sopenharmony_ci	* **new** - This is for using a new operator for creating a message instance.
8ffe3c632Sopenharmony_ci    * **new arena** - This is for using arena for creating a new message instance.
9ffe3c632Sopenharmony_ci    * **reuse** - This is for reusing the same message instance for parsing.
10ffe3c632Sopenharmony_ci* **Java** - For Java, there are three parsing/serialization methods:
11ffe3c632Sopenharmony_ci	* **byte[]** - This is for parsing from a Byte Array.
12ffe3c632Sopenharmony_ci    * **ByteString** - This is for parsing from a
13ffe3c632Sopenharmony_ci    	com.google.protobuf.ByteString.
14ffe3c632Sopenharmony_ci    * **InputStream** - This is for parsing from an InputStream.
15ffe3c632Sopenharmony_ci* **Python** - For Python, there are three types of Python protobuf for testing:
16ffe3c632Sopenharmony_ci	* **C++-generated-code** - This is for using C++ generated code of the
17ffe3c632Sopenharmony_ci    	proto file as a dynamic linked library.
18ffe3c632Sopenharmony_ci	* **C++-reflection** - This is for using C++ reflection, for which there's no
19ffe3c632Sopenharmony_ci    	generated code, but still using C++ protobuf library as a dynamic linked
20ffe3c632Sopenharmony_ci        library.
21ffe3c632Sopenharmony_ci	* **pure-Python** - This is for the pure version of Python, which does not link with
22ffe3c632Sopenharmony_ci    	any C++ protobuf library.
23ffe3c632Sopenharmony_ci
24ffe3c632Sopenharmony_ci## Parsing performance
25ffe3c632Sopenharmony_ci
26ffe3c632Sopenharmony_ci<table>
27ffe3c632Sopenharmony_ci<tbody><tr>
28ffe3c632Sopenharmony_ci<th rowspan="2"> </th>
29ffe3c632Sopenharmony_ci<th colspan="3" rowspan="1">C++</th>
30ffe3c632Sopenharmony_ci<th colspan="3" rowspan="1">C++ with tcmalloc</th>
31ffe3c632Sopenharmony_ci<th colspan="3" rowspan="1">java</th>
32ffe3c632Sopenharmony_ci<th colspan="3" rowspan="1">python</th>
33ffe3c632Sopenharmony_ci</tr>
34ffe3c632Sopenharmony_ci<tr>
35ffe3c632Sopenharmony_ci<th colspan="1">new</th>
36ffe3c632Sopenharmony_ci<th colspan="1">new arena</th>
37ffe3c632Sopenharmony_ci<th colspan="1">reuse</th>
38ffe3c632Sopenharmony_ci<th colspan="1">new</th>
39ffe3c632Sopenharmony_ci<th colspan="1">new arena</th>
40ffe3c632Sopenharmony_ci<th colspan="1">reuse</th>
41ffe3c632Sopenharmony_ci<th colspan="1">byte[]</th>
42ffe3c632Sopenharmony_ci<th colspan="1">ByteString</th>
43ffe3c632Sopenharmony_ci<th colspan="1">InputStream</th>
44ffe3c632Sopenharmony_ci<th colspan="1">C++-generated-code</th>
45ffe3c632Sopenharmony_ci<th colspan="1">C++-reflection</th>
46ffe3c632Sopenharmony_ci<th colspan="1">pure-Python</th>
47ffe3c632Sopenharmony_ci</tr>
48ffe3c632Sopenharmony_ci<tr>
49ffe3c632Sopenharmony_ci<td>google_message1_proto2</td>
50ffe3c632Sopenharmony_ci<td>368.717MB/s</td>
51ffe3c632Sopenharmony_ci<td>261.847MB/s</td>
52ffe3c632Sopenharmony_ci<td>799.403MB/s</td>
53ffe3c632Sopenharmony_ci<td>645.183MB/s</td>
54ffe3c632Sopenharmony_ci<td>441.023MB/s</td>
55ffe3c632Sopenharmony_ci<td>1.122GB/s</td>
56ffe3c632Sopenharmony_ci<td>425.437MB/s</td>
57ffe3c632Sopenharmony_ci<td>425.937MB/s</td>
58ffe3c632Sopenharmony_ci<td>251.018MB/s</td>
59ffe3c632Sopenharmony_ci<td>82.8314MB/s</td>
60ffe3c632Sopenharmony_ci<td>47.6763MB/s</td>
61ffe3c632Sopenharmony_ci<td>3.76299MB/s</td>
62ffe3c632Sopenharmony_ci</tr>
63ffe3c632Sopenharmony_ci<tr>
64ffe3c632Sopenharmony_ci<td>google_message1_proto3</td>
65ffe3c632Sopenharmony_ci<td>294.517MB/s</td>
66ffe3c632Sopenharmony_ci<td>229.116MB/s</td>
67ffe3c632Sopenharmony_ci<td>469.982MB/s</td>
68ffe3c632Sopenharmony_ci<td>434.510MB/s</td>
69ffe3c632Sopenharmony_ci<td>394.701MB/s</td>
70ffe3c632Sopenharmony_ci<td>591.931MB/s</td>
71ffe3c632Sopenharmony_ci<td>357.597MB/s</td>
72ffe3c632Sopenharmony_ci<td>378.568MB/s</td>
73ffe3c632Sopenharmony_ci<td>221.676MB/s</td>
74ffe3c632Sopenharmony_ci<td>82.0498MB/s</td>
75ffe3c632Sopenharmony_ci<td>39.9467MB/s</td>
76ffe3c632Sopenharmony_ci<td>3.77751MB/s</td>
77ffe3c632Sopenharmony_ci</tr>
78ffe3c632Sopenharmony_ci<tr>
79ffe3c632Sopenharmony_ci<td>google_message2</td>
80ffe3c632Sopenharmony_ci<td>277.242MB/s</td>
81ffe3c632Sopenharmony_ci<td>347.611MB/s</td>
82ffe3c632Sopenharmony_ci<td>793.67MB/s</td>
83ffe3c632Sopenharmony_ci<td>503.721MB/s</td>
84ffe3c632Sopenharmony_ci<td>596.333MB/s</td>
85ffe3c632Sopenharmony_ci<td>922.533MB/s</td>
86ffe3c632Sopenharmony_ci<td>416.778MB/s</td>
87ffe3c632Sopenharmony_ci<td>419.543MB/s</td>
88ffe3c632Sopenharmony_ci<td>367.145MB/s</td>
89ffe3c632Sopenharmony_ci<td>241.46MB/s</td>
90ffe3c632Sopenharmony_ci<td>71.5723MB/s</td>
91ffe3c632Sopenharmony_ci<td>2.73538MB/s</td>
92ffe3c632Sopenharmony_ci</tr>
93ffe3c632Sopenharmony_ci<tr>
94ffe3c632Sopenharmony_ci<td>google_message3_1</td>
95ffe3c632Sopenharmony_ci<td>213.478MB/s</td>
96ffe3c632Sopenharmony_ci<td>291.58MB/s</td>
97ffe3c632Sopenharmony_ci<td>543.398MB/s</td>
98ffe3c632Sopenharmony_ci<td>539.704MB/s</td>
99ffe3c632Sopenharmony_ci<td>717.300MB/s</td>
100ffe3c632Sopenharmony_ci<td>927.333MB/s</td>
101ffe3c632Sopenharmony_ci<td>684.241MB/s</td>
102ffe3c632Sopenharmony_ci<td>704.47MB/s</td>
103ffe3c632Sopenharmony_ci<td>648.624MB/s</td>
104ffe3c632Sopenharmony_ci<td>209.036MB/s</td>
105ffe3c632Sopenharmony_ci<td>142.356MB/s</td>
106ffe3c632Sopenharmony_ci<td>15.3324MB/s</td>
107ffe3c632Sopenharmony_ci</tr>
108ffe3c632Sopenharmony_ci<tr>
109ffe3c632Sopenharmony_ci<td>google_message3_2</td>
110ffe3c632Sopenharmony_ci<td>672.685MB/s</td>
111ffe3c632Sopenharmony_ci<td>802.767MB/s</td>
112ffe3c632Sopenharmony_ci<td>1.21505GB/s</td>
113ffe3c632Sopenharmony_ci<td>985.790MB/s</td>
114ffe3c632Sopenharmony_ci<td>1.136GB/s</td>
115ffe3c632Sopenharmony_ci<td>1.367GB/s</td>
116ffe3c632Sopenharmony_ci<td>1.54439GB/s</td>
117ffe3c632Sopenharmony_ci<td>1.60603GB/s</td>
118ffe3c632Sopenharmony_ci<td>1.33443GB/s</td>
119ffe3c632Sopenharmony_ci<td>573.835MB/s</td>
120ffe3c632Sopenharmony_ci<td>314.33MB/s</td>
121ffe3c632Sopenharmony_ci<td>15.0169MB/s</td>
122ffe3c632Sopenharmony_ci</tr>
123ffe3c632Sopenharmony_ci<tr>
124ffe3c632Sopenharmony_ci<td>google_message3_3</td>
125ffe3c632Sopenharmony_ci<td>207.681MB/s</td>
126ffe3c632Sopenharmony_ci<td>140.591MB/s</td>
127ffe3c632Sopenharmony_ci<td>535.181MB/s</td>
128ffe3c632Sopenharmony_ci<td>369.743MB/s</td>
129ffe3c632Sopenharmony_ci<td>262.301MB/s</td>
130ffe3c632Sopenharmony_ci<td>556.644MB/s</td>
131ffe3c632Sopenharmony_ci<td>279.385MB/s</td>
132ffe3c632Sopenharmony_ci<td>304.853MB/s</td>
133ffe3c632Sopenharmony_ci<td>107.575MB/s</td>
134ffe3c632Sopenharmony_ci<td>32.248MB/s</td>
135ffe3c632Sopenharmony_ci<td>26.1431MB/s</td>
136ffe3c632Sopenharmony_ci<td>2.63541MB/s</td>
137ffe3c632Sopenharmony_ci</tr>
138ffe3c632Sopenharmony_ci<tr>
139ffe3c632Sopenharmony_ci<td>google_message3_4</td>
140ffe3c632Sopenharmony_ci<td>7.96091GB/s</td>
141ffe3c632Sopenharmony_ci<td>7.10024GB/s</td>
142ffe3c632Sopenharmony_ci<td>9.3013GB/s</td>
143ffe3c632Sopenharmony_ci<td>8.518GB/s</td>
144ffe3c632Sopenharmony_ci<td>8.171GB/s</td>
145ffe3c632Sopenharmony_ci<td>9.917GB/s</td>
146ffe3c632Sopenharmony_ci<td>5.78006GB/s</td>
147ffe3c632Sopenharmony_ci<td>5.85198GB/s</td>
148ffe3c632Sopenharmony_ci<td>4.62609GB/s</td>
149ffe3c632Sopenharmony_ci<td>2.49631GB/s</td>
150ffe3c632Sopenharmony_ci<td>2.35442GB/s</td>
151ffe3c632Sopenharmony_ci<td>802.061MB/s</td>
152ffe3c632Sopenharmony_ci</tr>
153ffe3c632Sopenharmony_ci<tr>
154ffe3c632Sopenharmony_ci<td>google_message3_5</td>
155ffe3c632Sopenharmony_ci<td>76.0072MB/s</td>
156ffe3c632Sopenharmony_ci<td>51.6769MB/s</td>
157ffe3c632Sopenharmony_ci<td>237.856MB/s</td>
158ffe3c632Sopenharmony_ci<td>178.495MB/s</td>
159ffe3c632Sopenharmony_ci<td>111.751MB/s</td>
160ffe3c632Sopenharmony_ci<td>329.569MB/s</td>
161ffe3c632Sopenharmony_ci<td>121.038MB/s</td>
162ffe3c632Sopenharmony_ci<td>132.866MB/s</td>
163ffe3c632Sopenharmony_ci<td>36.9197MB/s</td>
164ffe3c632Sopenharmony_ci<td>10.3962MB/s</td>
165ffe3c632Sopenharmony_ci<td>8.84659MB/s</td>
166ffe3c632Sopenharmony_ci<td>1.25203MB/s</td>
167ffe3c632Sopenharmony_ci</tr>
168ffe3c632Sopenharmony_ci<tr>
169ffe3c632Sopenharmony_ci<td>google_message4</td>
170ffe3c632Sopenharmony_ci<td>331.46MB/s</td>
171ffe3c632Sopenharmony_ci<td>404.862MB/s</td>
172ffe3c632Sopenharmony_ci<td>427.99MB/s</td>
173ffe3c632Sopenharmony_ci<td>589.887MB/s</td>
174ffe3c632Sopenharmony_ci<td>720.367MB/s</td>
175ffe3c632Sopenharmony_ci<td>705.373MB/s</td>
176ffe3c632Sopenharmony_ci<td>606.228MB/s</td>
177ffe3c632Sopenharmony_ci<td>589.13MB/s</td>
178ffe3c632Sopenharmony_ci<td>530.692MB/s</td>
179ffe3c632Sopenharmony_ci<td>305.543MB/s</td>
180ffe3c632Sopenharmony_ci<td>174.834MB/s</td>
181ffe3c632Sopenharmony_ci<td>7.86485MB/s</td>
182ffe3c632Sopenharmony_ci</tr>
183ffe3c632Sopenharmony_ci</tbody></table>
184ffe3c632Sopenharmony_ci
185ffe3c632Sopenharmony_ci## Serialization performance
186ffe3c632Sopenharmony_ci
187ffe3c632Sopenharmony_ci<table>
188ffe3c632Sopenharmony_ci<tbody><tr>
189ffe3c632Sopenharmony_ci<th rowspan="2"> </th>
190ffe3c632Sopenharmony_ci<th colspan="1" rowspan="2">C++</th>
191ffe3c632Sopenharmony_ci<th colspan="1" rowspan="2">C++ with tcmalloc</th>
192ffe3c632Sopenharmony_ci<th colspan="3" rowspan="1">java</th>
193ffe3c632Sopenharmony_ci<th colspan="3" rowspan="1">python</th>
194ffe3c632Sopenharmony_ci</tr>
195ffe3c632Sopenharmony_ci<tr>
196ffe3c632Sopenharmony_ci<th colspan="1">byte[]</th>
197ffe3c632Sopenharmony_ci<th colspan="1">ByteString</th>
198ffe3c632Sopenharmony_ci<th colspan="1">InputStream</th>
199ffe3c632Sopenharmony_ci<th colspan="1">C++-generated-code</th>
200ffe3c632Sopenharmony_ci<th colspan="1">C++-reflection</th>
201ffe3c632Sopenharmony_ci<th colspan="1">pure-Python</th>
202ffe3c632Sopenharmony_ci</tr>
203ffe3c632Sopenharmony_ci<tr>
204ffe3c632Sopenharmony_ci<td>google_message1_proto2</td>
205ffe3c632Sopenharmony_ci<td>1.39698GB/s</td>
206ffe3c632Sopenharmony_ci<td>1.701GB/s</td>
207ffe3c632Sopenharmony_ci<td>1.12915GB/s</td>
208ffe3c632Sopenharmony_ci<td>1.13589GB/s</td>
209ffe3c632Sopenharmony_ci<td>758.609MB/s</td>
210ffe3c632Sopenharmony_ci<td>260.911MB/s</td>
211ffe3c632Sopenharmony_ci<td>58.4815MB/s</td>
212ffe3c632Sopenharmony_ci<td>5.77824MB/s</td>
213ffe3c632Sopenharmony_ci</tr>
214ffe3c632Sopenharmony_ci<tr>
215ffe3c632Sopenharmony_ci<td>google_message1_proto3</td>
216ffe3c632Sopenharmony_ci<td>959.305MB/s</td>
217ffe3c632Sopenharmony_ci<td>939.404MB/s</td>
218ffe3c632Sopenharmony_ci<td>1.15372GB/s</td>
219ffe3c632Sopenharmony_ci<td>1.07824GB/s</td>
220ffe3c632Sopenharmony_ci<td>802.337MB/s</td>
221ffe3c632Sopenharmony_ci<td>239.4MB/s</td>
222ffe3c632Sopenharmony_ci<td>33.6336MB/s</td>
223ffe3c632Sopenharmony_ci<td>5.80524MB/s</td>
224ffe3c632Sopenharmony_ci</tr>
225ffe3c632Sopenharmony_ci<tr>
226ffe3c632Sopenharmony_ci<td>google_message2</td>
227ffe3c632Sopenharmony_ci<td>1.27429GB/s</td>
228ffe3c632Sopenharmony_ci<td>1.402GB/s</td>
229ffe3c632Sopenharmony_ci<td>1.01039GB/s</td>
230ffe3c632Sopenharmony_ci<td>1022.99MB/s</td>
231ffe3c632Sopenharmony_ci<td>798.736MB/s</td>
232ffe3c632Sopenharmony_ci<td>996.755MB/s</td>
233ffe3c632Sopenharmony_ci<td>57.9601MB/s</td>
234ffe3c632Sopenharmony_ci<td>4.09246MB/s</td>
235ffe3c632Sopenharmony_ci</tr>
236ffe3c632Sopenharmony_ci<tr>
237ffe3c632Sopenharmony_ci<td>google_message3_1</td>
238ffe3c632Sopenharmony_ci<td>1.31916GB/s</td>
239ffe3c632Sopenharmony_ci<td>2.049GB/s</td>
240ffe3c632Sopenharmony_ci<td>991.496MB/s</td>
241ffe3c632Sopenharmony_ci<td>860.332MB/s</td>
242ffe3c632Sopenharmony_ci<td>662.88MB/s</td>
243ffe3c632Sopenharmony_ci<td>1.48625GB/s</td>
244ffe3c632Sopenharmony_ci<td>421.287MB/s</td>
245ffe3c632Sopenharmony_ci<td>18.002MB/s</td>
246ffe3c632Sopenharmony_ci</tr>
247ffe3c632Sopenharmony_ci<tr>
248ffe3c632Sopenharmony_ci<td>google_message3_2</td>
249ffe3c632Sopenharmony_ci<td>2.15676GB/s</td>
250ffe3c632Sopenharmony_ci<td>2.632GB/s</td>
251ffe3c632Sopenharmony_ci<td>2.14736GB/s</td>
252ffe3c632Sopenharmony_ci<td>2.08136GB/s</td>
253ffe3c632Sopenharmony_ci<td>1.55997GB/s</td>
254ffe3c632Sopenharmony_ci<td>2.39597GB/s</td>
255ffe3c632Sopenharmony_ci<td>326.777MB/s</td>
256ffe3c632Sopenharmony_ci<td>16.0527MB/s</td>
257ffe3c632Sopenharmony_ci</tr>
258ffe3c632Sopenharmony_ci<tr>
259ffe3c632Sopenharmony_ci<td>google_message3_3</td>
260ffe3c632Sopenharmony_ci<td>650.456MB/s</td>
261ffe3c632Sopenharmony_ci<td>1.040GB/s</td>
262ffe3c632Sopenharmony_ci<td>593.52MB/s</td>
263ffe3c632Sopenharmony_ci<td>580.667MB/s</td>
264ffe3c632Sopenharmony_ci<td>346.839MB/s</td>
265ffe3c632Sopenharmony_ci<td>123.978MB/s</td>
266ffe3c632Sopenharmony_ci<td>35.893MB/s</td>
267ffe3c632Sopenharmony_ci<td>2.32834MB/s</td>
268ffe3c632Sopenharmony_ci</tr>
269ffe3c632Sopenharmony_ci<tr>
270ffe3c632Sopenharmony_ci<td>google_message3_4</td>
271ffe3c632Sopenharmony_ci<td>8.70154GB/s</td>
272ffe3c632Sopenharmony_ci<td>9.825GB/s</td>
273ffe3c632Sopenharmony_ci<td>5.88645GB/s</td>
274ffe3c632Sopenharmony_ci<td>5.93946GB/s</td>
275ffe3c632Sopenharmony_ci<td>2.44388GB/s</td>
276ffe3c632Sopenharmony_ci<td>5.9241GB/s</td>
277ffe3c632Sopenharmony_ci<td>4.05837GB/s</td>
278ffe3c632Sopenharmony_ci<td>876.87MB/s</td>
279ffe3c632Sopenharmony_ci</tr>
280ffe3c632Sopenharmony_ci<tr>
281ffe3c632Sopenharmony_ci<td>google_message3_5</td>
282ffe3c632Sopenharmony_ci<td>246.33MB/s</td>
283ffe3c632Sopenharmony_ci<td>443.993MB/s</td>
284ffe3c632Sopenharmony_ci<td>283.278MB/s</td>
285ffe3c632Sopenharmony_ci<td>259.167MB/s</td>
286ffe3c632Sopenharmony_ci<td>206.37MB/s</td>
287ffe3c632Sopenharmony_ci<td>37.0285MB/s</td>
288ffe3c632Sopenharmony_ci<td>12.2228MB/s</td>
289ffe3c632Sopenharmony_ci<td>1.1979MB/s</td>
290ffe3c632Sopenharmony_ci</tr>
291ffe3c632Sopenharmony_ci<tr>
292ffe3c632Sopenharmony_ci<td>google_message4</td>
293ffe3c632Sopenharmony_ci<td>1.56674GB/s</td>
294ffe3c632Sopenharmony_ci<td>2.19601GB/s</td>
295ffe3c632Sopenharmony_ci<td>776.907MB/s</td>
296ffe3c632Sopenharmony_ci<td>770.707MB/s</td>
297ffe3c632Sopenharmony_ci<td>702.931MB/s</td>
298ffe3c632Sopenharmony_ci<td>1.49623GB/s</td>
299ffe3c632Sopenharmony_ci<td>205.116MB/s</td>
300ffe3c632Sopenharmony_ci<td>8.93428MB/s</td>
301ffe3c632Sopenharmony_ci</tr>
302ffe3c632Sopenharmony_ci</tbody></table>
303ffe3c632Sopenharmony_ci
304ffe3c632Sopenharmony_ci\* The cpp performance can be improved by using [tcmalloc](https://gperftools.github.io/gperftools/tcmalloc.html), please follow the (instruction)[https://github.com/protocolbuffers/protobuf/blob/master/benchmarks/README.md] to link with tcmalloc to get the faster result.
305