Why is binary serialization faster than xml serialization?

前端 未结 5 2271
别那么骄傲
别那么骄傲 2021-02-19 20:25

Why is binary serialization considered faster than xml serialization?

5条回答
  •  自闭症患者
    2021-02-19 21:12

    Consider serializing double for example:

    • binary serialization: writing 8 bytes from memory address to the stream

    • binary deserialization: reading same 8 bytes

    • xml serialization: writing tag, converting to text, writing closing tag - nearly thrice the I/O and 1000x more CPU utilization

    • xml deserialization: tag reading/validation, reading string parsing it to number, reading/validation of closing tag. little more overhead for I/O and some more for CPU

提交回复
热议问题