Golang object serialization and deserialization

Source: Internet
Author: User
Tags object serialization
This is a creation in Article, where the information may have evolved or changed. Simulation test 1,000, 000 data per 10 bytes or less than 10M of data (highly structured data)
Process
1. Object serialized to Byte

2.byte reverse order As Object

3.gzip Compressed byte

Test language Go
Test scenario: Raw Byte,json, Bson, Msgpack (Protostuff need to do the object configuration file, more cumbersome, usually think and msgpack performance equivalent)
Result: Msgpack wins


Size
Gzip size after compression
object to byte time consuming
Byte-to-object time-consuming
Raw 10000000
6573252 (65%) Not tested
Not tested
Json
47515988 7919511 (17%) 3248ms 5280ms
Bson
49888910 9506965 (19%)
3863ms 6235ms
Msgpack
29934223 7448484 2046ms 3113ms


Raw data:1000000
Raw data gzip compress:6573252//gzip size after compression

start:1000000
Marshal cost:3248//json Serialization Time-consuming
JSON string:47515988
JSON byte:47515988//binary array size
Unmarshal cost:5280//json deserialization time-consuming
Test data: {1 100 0.9405091}
JSON gzip compress:7919511//gzip size after compression

Start
Marshal cost:3863
Bson byte:49888910
Unmarshal cost:6235
Test data: {1 100 0.9405091}
Bson gzip compress:9506965


start:1000000
Marshal cost:2046
msgpack:29934223
Unmarshal cost:3113
Test data: {1 100 0.9405091}
Msgpack gzip compress:7448484










Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.