Why is binary serialization faster than xml serialization?

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

Why is binary serialization considered faster than xml serialization?

5条回答
  •  暖寄归人
    2021-02-19 20:59

    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

提交回复
热议问题