WARNING: Benchmarks can be misleading.
In short, before you make a decision on which tool to use, make sure you try it out in an environment you care about. To start, download the benchmark code and run it onyour hardware with data valuesyou care about.
Hardware: Intel I7 2600k (3.4 – 3.8Ghz)
Software: Sun JRE 1.6.0_26 (64-bit server VM), Ubuntu 11.04
JVM options: -Xmx16m -server
Data value being tested: TestValue.
Version of the benchmarking code: Git tree
Methodology:
Tool Versions ( lib/):
(“manual” labels in charts shortened to “M”.)
Create an object, serialize it to a byte array, then deserialize it back to an object.
Create an object, serialize it to a byte array.
Often the most expensive operation. To make a fair comparison, all fields of the deserialized instances are accessed – this forces lazy deserializers to really do their work. The raw data below shows additional measurements for deserialization.
The size of the serialized data. These numbers may vary depending on the exact data value being used.
The size of the serialized data compressed with Java’s built-in implementation ofDEFLATE (zlib).
Object creation is not so meaningful since it takes in average 100 nano to create an object. However, the different tools vary in how “fancy” their objects are. Some just create a plain Java class and let you access fields directly, while others have set/get methods, while others use the “builder” pattern.
Times are in nanoseconds, sizes are in bytes.
create ser +same deser +shal +deep total size +dfl java-built-in 109 6338 5624 33940 33967 34203 40542 889 514 java-manual 104 1022 919 725 767 830 1852 255 147 scala/java-built-in 341 9639 8105 49672 50273 50364 60003 1312 700 scala/sbinary 308 2275 2052 1531 1635 1884 4160 255 147 hessian 110 4772 4193 6995 7104 7162 11934 501 313 kryo 117 1325 1210 1398 1425 1486 2811 233 147 kryo-opt 112 1126 1011 1242 1286 1336 2462 219 135 kryo-manual 118 1083 960 1021 1065 1097 2180 219 132 protobuf 294 2378 1007 1088 1124 1382 3760 239 149 protobuf/activemq+alt 193 2502 5 7 710 1482 3984 239 149 protostuff 139 667 530 1055 1083 1171 1838 239 150 protostuff-manual 118 637 537 934 973 1050 1687 239 150 protostuff-runtime 119 859 759 1260 1303 1336 2195 241 151 protobuf/protostuff 156 709 581 1071 1100 1164 1873 239 149 thrift 234 2548 2332 1351 1381 1471 4019 349 197 thrift-compact 219 2395 2138 1470 1537 1646 4041 240 148 avro 188 2625 2442 1400 1818 2368 4993 221 133 avro-generic 544 2892 2331 1150 1731 2404 5297 221 133 msgpack/dynamic 119 1762 1662 1317 1557 1550 3312 233 146 json/jackson-manual 112 1426 1307 2180 2192 2285 3711 468 253 json/jackson-manual/tree 122 2948 2861 3396 3442 3578 6525 485 259 json/jackson-manual/tree-strings 114 4085 3841 4406 4404 4519 8605 485 259 json/jackson-databind 115 2293 2074 3236 3299 3422 5715 503 271 json/jackson-databind-strings 123 3104 2901 4252 4359 4476 7580 503 271 json/protostuff-manual 119 1604 1422 2147 2186 2262 3866 449 233 json/protostuff-runtime 115 2051 1835 2536 2576 2689 4740 469 243 json/protobuf 285 12306 11607 83253 83620 84137 96444 488 253 json/google-gson/manual 112 6097 5964 5449 5504 5548 11645 468 253 json/google-gson/manual/tree 121 8297 8676 10451 10530 10955 19252 485 259 json/google-gson/databind 118 28208 27836 32526 32719 32894 61102 486 259 json/svenson-databind 115 5532 5267 15785 15747 15865 21396 495 268 json/flexjson/databind 116 27763 27559 70925 71118 71819 99582 503 273 json/json-lib-databind 118 39954 43557 118112 116565 121168 161123 485 263 json/fastjson-databind 116 2942 2773 4194 4234 4362 7303 478 254 json/json.simple/manual 122 8645 8319 10716 10642 10882 19527 495 269 json/json.simple/manual/tree 118 8336 8480 11747 11680 11906 20242 495 269 json/json-smart/manual/tree 117 7060 6810 4282 4279 4390 11450 495 269 json/org.json/manual/tree 117 8930 8797 10497 10813 11077 20007 485 259 json/jsonij-jpath 117 44052 45082 16807 16711 16699 60751 478 254 json/jsonij-manual/tree 119 44208 43262 8330 8523 8547 52755 478 254 json/argo-manual/tree 121 125007 125486 19256 19543 19323 144330 485 263 json/jsonpath/json.simple 118 8564 8336 354889 351264 376660 385224 495 269 bson/jackson-manual 124 5114 5015 6690 6766 6930 12043 495 278 bson/jackson-databind 124 6720 6217 8256 8285 8461 15181 519 295 bson/mongodb 117 4416 4268 13829 15456 15132 19548 495 278 smile/jackson-manual 127 1263 1126 1473 1503 1579 2842 341 244 smile/jackson-databind 127 2162 2021 2589 2651 2768 4929 364 259 smile/protostuff-manual 120 1467 1350 1687 1740 1793 3261 321 229 smile/protostuff-runtime 120 1693 1574 1958 1993 2071 3764 335 235 xml/woodstox-manual 123 4185 3985 5065 5134 5273 9457 653 304 xml/aalto-manual 127 2459 2346 3567 3631 3801 6260 653 304 xml/fastinfo-manual 124 7791 7435 7565 7826 7625 15417 377 284 xml/xstream+c 120 6694 5985 22916 23519 21833 28527 487 244 xml/xstream+c-woodstox 120 6177 5568 12877 13091 13067 19244 525 273 xml/xstream+c-aalto 119 5135 4548 10474 10635 10692 15827 525 273 xml/xstream+c-fastinfo 120 9762 8671 10533 10441 10910 20672 345 264 xml/jackson-databind/aalto 118 4252 3891 6308 6460 6652 10903 712 298 xml/javolution 122 7859 7473 8875 9031 9169 17028 504 263
Columns:
参见:https://github.com/eishay/jvm-serializers/wiki