Why is binary serialization faster than xml serialization?

前端 未结 5 1425
无人共我
无人共我 2021-02-19 20:46

Why is binary serialization considered faster than xml serialization?

5条回答
  •  余生分开走
    2021-02-19 21:19

    I had assumed binary serialization to be faster than xml (based on how verbose xml can be). However I have an opposite observation! I was investigating a performance issue in one of my application and find out that time to serialize is similar between xml and binary. However difference in time to deserialization is extremely huge. xml deserialization takes less than 10 seconds but binary deserialization takes over 10 minutes!

    So I guess in theory xml serialization/deseriliaztion is slower than binary but in your application, it depends!

    I can't share the actual data but here are the results (in milliseconds)

     Serialization   Deserialization    
     XML    Binary   XML    Binary 
     7,956  9,535    9,112  668,918 
     7,608  9,105    8,386  670,445 
     7,583  9,398    8,372  676,190 
     7,656  9,299    9,783  679,117 
     7,454  9,458    8,219  669,626 

提交回复
热议问题