{"id":13676812,"url":"https://github.com/smallnest/gosercomp","last_synced_at":"2025-04-05T17:07:43.150Z","repository":{"id":47419345,"uuid":"43280943","full_name":"smallnest/gosercomp","owner":"smallnest","description":":zap: Golang Serializer Benchmark Comparison","archived":false,"fork":false,"pushed_at":"2022-12-12T06:28:27.000Z","size":626,"stargazers_count":417,"open_issues_count":1,"forks_count":50,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-03-29T16:07:56.226Z","etag":null,"topics":["colfer","flatbuffers","gencode","gogo","golang","json","messagepack","protobuf","serializer","thrift"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smallnest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-28T05:08:59.000Z","updated_at":"2024-12-26T03:32:19.000Z","dependencies_parsed_at":"2023-01-27T15:00:33.292Z","dependency_job_id":null,"html_url":"https://github.com/smallnest/gosercomp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fgosercomp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fgosercomp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fgosercomp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fgosercomp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallnest","download_url":"https://codeload.github.com/smallnest/gosercomp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colfer","flatbuffers","gencode","gogo","golang","json","messagepack","protobuf","serializer","thrift"],"created_at":"2024-08-02T13:00:33.247Z","updated_at":"2025-04-05T17:07:43.125Z","avatar_url":"https://github.com/smallnest.png","language":"Go","readme":"## Golang Serialization Benchmark\n\n### Serializers\n\nThis project test the below go serializers, which compares with go standard _json_ and _xml_.\n\n- [encoding/json](http://golang.org/pkg/encoding/json/)\n- [encoding/xml](http://golang.org/pkg/encoding/xml/)\n- [github.com/tinylib/msgp](http://github.com/tinylib/msgp)\n- [github.com/golang/protobuf](http://github.com/golang/protobuf)\n- [github.com/gogo/protobuf](http://github.com/gogo/protobuf)\n- [Apache/Thrift](https://github.com/apache/thrift/tree/master/lib/go)\n- [Apache/Avro](https://github.com/linkedin/goavro)\n- [andyleap/gencode](https://github.com/andyleap/gencode)\n- [ugorji/go/codec](https://github.com/ugorji/go/tree/master/codec)\n- [colfer](https://github.com/pascaldekloe/colfer)\n- [zebrapack](https://github.com/glycerine/zebrapack)\n- [gotiny](https://github.com/niubaoshu/gotiny)\n- [github.com/ugorji/go/codec](http://github.com/ugorji/go/codec)\n- [hprose-golang](https://github.com/hprose/hprose-golang/tree/master/io)\n- [vmihailenco/msgpack/v4](https://github.com/vmihailenco/msgpack)\n- [Sereal](https://github.com/Sereal/Sereal)\n- [ffjson](https://github.com/pquerna/ffjson)\n- [easyjson](https://github.com/mailru/easyjson)\n- [jsoniter](https://github.com/json-iterator/go)\n- [go-ethereum/rlp](https://github.com/ethereum/go-ethereum)\n- [go-memdump](https://github.com/alexflint/go-memdump)\n\n### Excluded Serializers\n\nGiven existed [benchmark](https://github.com/alecthomas/go_serialization_benchmarks) by alecthomas，or complexity， or activity, the below serializers are excluded from this test because of their poor performance.\n\n- [encoding/gob](http://golang.org/pkg/encoding/gob/)\n- [github.com/alecthomas/binary](http://github.com/alecthomas/binary)\n- [github.com/davecgh/go-xdr/xdr](http://github.com/davecgh/go-xdr/xdr)\n- [labix.org/v2/mgo/bson](http://labix.org/v2/mgo/bson)\n- [github.com/DeDiS/protobuf](http://github.com/DeDiS/protobuf)\n- [bson](http://github.com/micro/go-bson)\n- [github.com/google/flatbuffers](http://github.com/google/flatbuffers)\n\n### Test Environment\n\ngo version: **1.13.4**\n\n**Test:**\n\n```\ngo test -bench=.\n```\n\n### Test Data Model\n\nAll tests are using the same data model as below:\n\n```go\ntype ColorGroup struct {\n    ID     int `json:\"id\" xml:\"id,attr\"\"`\n    Name   string `json:\"name\" xml:\"name\"`\n    Colors []string `json:\"colors\" xml:\"colors\"`\n}\n`\n```\n\n### Benchmark\n\n![](benchmark.png)\n\n**Marshal**\n\n_include marshalled bytes_\nThe test machine is the MacBook Pro 16 with i7 2.6GHz and 32G 2667MHz DDR4 memory.\nThe test command we use is `go test -benchtime=5s -bench=. -benchmem`\n\n```\nBenchmarkMarshalByJson-128                        \t14734310\t       410.2 ns/op\t        65.00 marshaledBytes\t     128 B/op\t       2 allocs/op\nBenchmarkMarshalByXml-128                         \t 1578195\t      3735 ns/op\t       137.0 marshaledBytes\t    4736 B/op\t      11 allocs/op\nBenchmarkMarshalByMsgp-128                        \t60867415\t        90.96 ns/op\t        47.00 marshaledBytes\t      80 B/op\t       1 allocs/op\nBenchmarkMarshalByProtoBuf-128                    \t18273046\t       327.0 ns/op\t        36.00 marshaledBytes\t      64 B/op\t       2 allocs/op\nBenchmarkMarshalByGogoProtoBuf-128                \t65710664\t        90.39 ns/op\t        36.00 marshaledBytes\t      48 B/op\t       1 allocs/op\nBenchmarkMarshalByThrift-128                      \t21794796\t       273.7 ns/op\t        63.00 marshaledBytes\t      64 B/op\t       1 allocs/op\nBenchmarkMarshalByThriftIterator-128              \t14869611\t       402.6 ns/op\t        63.00 marshaledBytes\t     248 B/op\t       6 allocs/op\nBenchmarkMarshalByThriftIteratorDynamic-128       \t14203106\t       423.2 ns/op\t        63.00 marshaledBytes\t     200 B/op\t       5 allocs/op\nBenchmarkMarshalByThriftIteratorEncoder-128       \t22899847\t       295.3 ns/op\t        63.00 marshaledBytes\t     187 B/op\t       0 allocs/op\nBenchmarkMarshalByAvro-128                        \t20259181\t       297.5 ns/op\t        32.00 marshaledBytes\t     112 B/op\t       2 allocs/op\nBenchmarkMarshalByGencode-128                     \t165538641\t        35.88 ns/op\t        34.00 marshaledBytes\t       0 B/op\t       0 allocs/op\nBenchmarkMarshalByUgorjiCodecAndCbor-128          \t 5353467\t      1103 ns/op\t        47.00 marshaledBytes\t    1504 B/op\t       6 allocs/op\nBenchmarkMarshalByUgorjiCodecAndMsgp-128          \t 5484471\t      1093 ns/op\t        47.00 marshaledBytes\t    1504 B/op\t       6 allocs/op\nBenchmarkMarshalByUgorjiCodecAndBinc-128          \t 5455846\t      1104 ns/op\t        47.00 marshaledBytes\t    1504 B/op\t       6 allocs/op\nBenchmarkMarshalByUgorjiCodecAndJson-128          \t 4621263\t      1291 ns/op\t        65.00 marshaledBytes\t    1584 B/op\t       6 allocs/op\nBenchmarkMarshalByEasyjson-128                    \t27812725\t       215.5 ns/op\t        65.00 marshaledBytes\t     128 B/op\t       1 allocs/op\nBenchmarkMarshalByFfjson-128                      \t 5023614\t      1190 ns/op\t        65.00 marshaledBytes\t     412 B/op\t       9 allocs/op\nBenchmarkMarshalByJsoniter-128                    \t17086744\t       350.6 ns/op\t        65.00 marshaledBytes\t      88 B/op\t       2 allocs/op\nBenchmarkMarshalBySonic-128                       \t20919127\t       288.6 ns/op\t        65.00 marshaledBytes\t     198 B/op\t       4 allocs/op\nBenchmarkMarshalByGojay-128                       \t13831465\t       430.9 ns/op\t        65.00 marshaledBytes\t     538 B/op\t       2 allocs/op\nBenchmarkMarshalByGoMemdump-128                   \t 1550764\t      3864 ns/op\t       200.0 marshaledBytes\t    1512 B/op\t      27 allocs/op\nBenchmarkMarshalByColfer-128                      \t216226507\t        27.93 ns/op\t        35.00 marshaledBytes\t       0 B/op\t       0 allocs/op\nBenchmarkMarshalByZebrapack-128                   \t46097662\t       133.0 ns/op\t       109.0 marshaledBytes\t     186 B/op\t       0 allocs/op\nBenchmarkMarshalByHprose-128                      \t25639276\t       233.2 ns/op\t        49.00 marshaledBytes\t      24 B/op\t       1 allocs/op\nBenchmarkMarshalBySereal-128                      \t 3448252\t      1724 ns/op\t        76.00 marshaledBytes\t     728 B/op\t      22 allocs/op\nBenchmarkMarshalByVmihMsgpackv4-128               \t11608585\t       516.2 ns/op\t        55.00 marshaledBytes\t     232 B/op\t       5 allocs/op\nBenchmarkMarshalByRlp-128                         \t22588225\t       266.8 ns/op\t        32.00 marshaledBytes\t      64 B/op\t       3 allocs/op\nBenchmarkMarshalBySegmentioJSON-128               \t 9633194\t       623.1 ns/op\t        65.00 marshaledBytes\t    1072 B/op\t       2 allocs/op\n\n```\n\n**Unmarshal**\n\n```\nBenchmarkUnmarshalByJson-128                      \t 3697374\t      1631 ns/op\t     264 B/op\t      10 allocs/op\nBenchmarkUnmarshalByXml-128                       \t  638480\t      9316 ns/op\t    2946 B/op\t      70 allocs/op\nBenchmarkUnmarshalByMsgp-128                      \t44057836\t       135.5 ns/op\t      32 B/op\t       5 allocs/op\nBenchmarkUnmarshalByProtoBuf-128                  \t 9628360\t       620.3 ns/op\t     176 B/op\t      11 allocs/op\nBenchmarkUnmarshalByGogoProtoBuf-128              \t16364524\t       370.0 ns/op\t     160 B/op\t      10 allocs/op\nBenchmarkUnmarshalByThrift-128                    \t10060344\t       591.0 ns/op\t      96 B/op\t       6 allocs/op\nBenchmarkUnmarshalByThriftIterator-128            \t14740503\t       407.5 ns/op\t     168 B/op\t       7 allocs/op\nBenchmarkUnmarshalByThriftIteratorDynamic-128     \t 5471894\t      1098 ns/op\t     592 B/op\t      18 allocs/op\nBenchmarkUnmarshalByThriftIteratorDecoder-128     \t 5110819\t      1162 ns/op\t     616 B/op\t      19 allocs/op\nBenchmarkUnmarshalByAvro-128                      \t  281683\t     21232 ns/op\t   12305 B/op\t     232 allocs/op\nBenchmarkUnmarshalByGencode-128                   \t59231443\t        99.60 ns/op\t      32 B/op\t       5 allocs/op\nBenchmarkUnmarshalByUgorjiCodecAndCbor-128        \t 5306976\t      1128 ns/op\t     656 B/op\t       8 allocs/op\nBenchmarkUnmarshalByUgorjiCodecAndMsgp-128        \t 4681980\t      1284 ns/op\t     768 B/op\t      10 allocs/op\nBenchmarkUnmarshalByUgorjiCodecAndBinc-128        \t 5368308\t      1118 ns/op\t     656 B/op\t       8 allocs/op\nBenchmarkUnmarshalByUgorjiCodecAndJson-128        \t 3233894\t      1865 ns/op\t    1168 B/op\t      10 allocs/op\nBenchmarkUnmarshalByEasyjson-128                  \t16066514\t       371.5 ns/op\t      32 B/op\t       5 allocs/op\nBenchmarkUnmarshalByFfjson-128                    \t 3694323\t      1620 ns/op\t     474 B/op\t      13 allocs/op\nBenchmarkUnmarshalByJsoniter-128                  \t16905810\t       354.9 ns/op\t      32 B/op\t       5 allocs/op\nBenchmarkUnmarshalBySonic-128                     \t24124342\t       247.9 ns/op\t      99 B/op\t       1 allocs/op\nBenchmarkUnmarshalByGojay-128                     \t 9106419\t       659.9 ns/op\t     281 B/op\t       9 allocs/op\nBenchmarkUnmarshalByGoMemdump-128                 \t 9233306\t       655.1 ns/op\t     736 B/op\t       9 allocs/op\nBenchmarkUnmarshalByColfer-128                    \t34182229\t       175.7 ns/op\t      96 B/op\t       6 allocs/op\nBenchmarkUnmarshalByZebrapack-128                 \t29730520\t       195.6 ns/op\t      32 B/op\t       5 allocs/op\nBenchmarkUnmarshalByHprose-128                    \t11646049\t       517.5 ns/op\t     272 B/op\t       9 allocs/op\nBenchmarkUnmarshalBySereal-128                    \t12377004\t       480.3 ns/op\t      80 B/op\t       6 allocs/op\nBenchmarkUnmarshalByVmihMsgpackv4-128             \t 7308202\t       818.5 ns/op\t     264 B/op\t      11 allocs/op\nBenchmarkUnmarshalByRlp-128                       \t 9474120\t       634.5 ns/op\t     104 B/op\t      11 allocs/op\nBenchmarkUnmarshalBySegmentioJSON-128             \t14143380\t       421.1 ns/op\t      32 B/op\t       5 allocs/op\n```\n\n**Marshaled Size**\n\n![](size.png)\n","funding_links":[],"categories":["JSON parsers \u0026 validators"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallnest%2Fgosercomp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallnest%2Fgosercomp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallnest%2Fgosercomp/lists"}