Why is JSON faster than BSON in node.js?

前端 未结 3 1487
礼貌的吻别
礼貌的吻别 2020-12-17 17:49

After reading this, there is a quote that stood out:

BSON is also designed to be fast to encode and decode. For example, integers are stored as 32 (or

3条回答
  •  情深已故
    2020-12-17 18:32

    I think you can't judge the performance only by looking at serialise/deserialize. You've simply chosen the wrong use-case for BSON. BSON shines in databases - where you can do do the calculations on the data, without the need to serialize them. Also storing and retrieving binary data such as images makes BSON more efficient, as you don't need to encode the data as Hex/BASE64 or similar.

    Try to make some calculations directly retrieving/storing the values in JSON and BSON. But use random access (not always the same item), so that the chance it is optimized under the hood is small.

提交回复
热议问题