HomejvmserializersGitHubWord文档下载推荐.docx
《HomejvmserializersGitHubWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《HomejvmserializersGitHubWord文档下载推荐.docx(5页珍藏版)》请在冰豆网上搜索。
Hardware:
IntelCore2Quad
Software:
SunJRE1.6.0_20(64-bitserverVM),Ubuntu9.10
JVMoptions:
-Xmx16m-server
Datavaluebeingtested:
TestValue.
Versionofthebenchmarkingcode:
Gittree
Methodology:
Beforetakingmeasurements,wewarmthingsupbyrunningthetestseveraltimes.
Foratest,measurethetimetakentoperform2000operations
(serialization,deserialization,etc.).Thendividetheresultby2000.
Runeachtest100timesandreportthebestresult.
Lookatthecodeformoredetails.BenchmarkRunner.java
ToolVersions(lib/):
protobuf2.3.0
thrift0.2.0
avro1.3.2
kryo1.0
hessian4.0.3
1.1-SNAPSHOT
scala2.8.0-rc1
sbinary0.3.1-SNAPSHOT
google-gson1.4
jackson1.5.1
javolution5.2.6
protostuff1.0.0.M3
woodstox4.0.7
aalto0.9.5
fast-infoset1.2.6
xstream1.3.1
Charts
TotalTime(“total”)
Createanobject,serializeittoabytearray,thendeserializeitbacktoanobject.
SerializationTime(“ser”)
Createanobject,serializeittoabytearray.
Java’sbuilt-inserializerfaithfullyrepresentsarbitraryobject
graphs,whichhurtsperformance.Alltheotherserializersflattenthe
structureouttoatree.
DeserializationTime(“deser+deep”)
Oftenthemostexpensiveoperation.Tomakeafaircomparison,all
fieldsofthedeserializedinstancesareaccessed–thisforceslazy
deserializerstoreallydotheirwork.Therawdatabelowshows
additionalmeasurementsfordeserialization.
SerializedSize(“size”)
Thesizeoftheserializeddata.Thesenumbersmayvarydependingontheexactdatavaluebeingused.
Java’sbuilt-inserializerstoresthefullclassnameinserialized
form.Soyoudon’tneedtoknowaheadoftimewhatkindofobject
you’rereadingin.
The‘scala’test,whichusesJava’sbuilt-inserialization,yieldsa
largerserializedrepresentationbecauseitusuallycreatesmoreJava
classesunderthehood.
SerializationCompressedSize(“size+dfl”)
ThesizeoftheserializeddatacompressedwithJava’sbuilt-inimplementationofDEFLATE(zlib).
ObjectCreationTime(“create”)
Objectcreationisnotsomeaningfulsinceittakesinaverage100
nanotocreateanobject.However,thedifferenttoolsvaryinhow
“fancy”theirobjectsare.SomejustcreateaplainJavaclassandlet
youaccessfieldsdirectly,whileothershaveset/getmethods,while
othersusethe“builder”pattern.
ProtobufandThriftusethe“builder”patterntocreateobjects,whichmakestheoperationmoreexpensive.
AvrostoresStringsinUTF8form.ThetimetakentoconvertfromJava“String”valuestoUTF-8
isincludedunder“create”,“ser”,“deser+shal”,and“deser+deep”,
whichisn’tquiterepresentativeofreal-worldusage.Realcodethat
usesAvromightbeabletokeepstringsinUTF-8
form,thusavoidingtheneedtoconvertbackandforth(inwhichcase
the“ser+same”and“deser”resultsmightbemoreaccuratereflectionsof
Avro’sperformance).
Numbers
Timesareinnanoseconds,sizesareinbytes.
createser+samedeser+shal+deeptotalsize+dfl
protobuf482411520872428251627316846239149
thrift408413938694609485148949032349195
thrift-compact406402835414881499752439271240149
protobuf/activemq+alt3684006923144427796784239149
protobuf/protostuff356139911232197227724363835239149
protobuf/protostuff-runtime225174516122228251025854330241150
protostuff-core-ge358132810672265234524863814239150
protostuff-runtime-ge225168615392273255226174303241151
kryo225210819482309238324684577233147
kryo-opt225200218522112218822614263219135
avro18574674275860657222800112675221133
avro-generic23805226252055576864793513161221133
hessian221110221008311824120081196322985501313
java-built-in224130251173859070595375975972785889517
java-manual225180816641301137814783285255147
scala/java-built-in75620788178558867689203898511106401312700
scala/sbinary748421433222900306133707583255147
json/jackson-manual2226648650445254481457411222398220
json/jackson-databind231104571010564016508667017127503270
json/protostuff3617749707349335049520812957382194
json/protostuff+numeric3577934749747874955510113036360191
json/protobuf5072228721118117870120792121540143828488253
json/google-gson2418225781695133003135203135314217571486259
xml/manual-woodstox2397031686894379704991716948495267
xml/manual-aalto2394680417959106031613510815495267
xml/manual-fastinfo224142451401716293170321730931553333250
xml/xstream2368532282668141576142139141402226724758313
xml/xstream+c229151401401049303493324780262942381205
woodstox-xstream2398759584340141817142207140461228056796344
woodstox-xstream+c221126741135524154243032457937253419236
aalto-xstream2258594682487137690140350138958224903796344
aalto-xstream+c22310812949516718169151733928151419236
fastinfo-xstream235104124100900123098124063123837227961444323
fastinfo-xstream+c234202511877623823241492432544576293227
xml/javolution2195732554688518926897114703432239
Columns:
create:
createanobject(usingtheclassesspecifiedbytheserializationtool)
ser:
createanobjectandserializeit
+same:
serializethesameobject(i.e.doesn’tincludecreationtime)
deser:
deserializeanobject
+shal:
deserializeanobjectandaccessthetop-levelfields
+deep:
deserializeanobjectandaccessallthefields
total:
create+serialize+deserializeandaccessallfields
size:
thesizeoftheserializeddata
+dfl:
thesizeoftheserializeddatacompressedwithJava’sbuilt-inimplementationofDEFLATE(zlib)