Skip to content

Commit

Permalink
use fair and represatative method to test all libs: don’t reuse bytes…
Browse files Browse the repository at this point in the history
….Buffer and always return bytes for marshaling
  • Loading branch information
smallnest committed Dec 23, 2019
1 parent 7a90389 commit e5b39b6
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 117 deletions.
98 changes: 49 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,59 +68,59 @@ type ColorGroup struct {
_include marshalled bytes_

```
BenchmarkMarshalByJson-4 1869745 634 ns/op 65.0 marshaledBytes
BenchmarkMarshalByXml-4 275817 3859 ns/op 137 marshaledBytes
BenchmarkMarshalByMsgp-4 10177845 114 ns/op 47.0 marshaledBytes
BenchmarkMarshalByProtoBuf-4 5958943 200 ns/op 36.0 marshaledBytes
BenchmarkMarshalByGogoProtoBuf-4 8599736 138 ns/op 36.0 marshaledBytes
BenchmarkMarshalByThrift-4 2524033 449 ns/op 63.0 marshaledBytes
BenchmarkMarshalByAvro-4 3502730 338 ns/op 32.0 marshaledBytes
BenchmarkMarshalByGencode-4 26821284 43.4 ns/op 34.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndCbor-4 2152038 555 ns/op 47.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndMsgp-4 2217151 538 ns/op 47.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndBinc-4 2119299 562 ns/op 47.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndJson-4 1622152 676 ns/op 65.0 marshaledBytes
BenchmarkMarshalByEasyjson-4 4240388 274 ns/op 65.0 marshaledBytes
BenchmarkMarshalByFfjson-4 1321222 902 ns/op 65.0 marshaledBytes
BenchmarkMarshalByJsoniter-4 2413506 493 ns/op 65.0 marshaledBytes
BenchmarkMarshalByGoMemdump-4 261883 4333 ns/op 200 marshaledBytes
BenchmarkMarshalByColfer-4 34064367 33.7 ns/op 35.0 marshaledBytes
BenchmarkMarshalByZebrapack-4 6609897 252 ns/op 109 marshaledBytes
BenchmarkMarshalByGotiny-4 3376788 348 ns/op 32.0 marshaledBytes
BenchmarkMarshalByHprose-4 3227366 367 ns/op 49.0 marshaledBytes
BenchmarkMarshalBySereal-4 481123 2132 ns/op 76.0 marshaledBytes
BenchmarkMarshalByMsgpackV2-4 894158 1373 ns/op 47.0 marshaledBytes
BenchmarkMarshalByRlp-4 2521772 477 ns/op 32.0 marshaledBytes
BenchmarkMarshalBySegmentioJSON-4 2069793 584 ns/op 65.0 marshaledBytes
BenchmarkMarshalByJson-4 1950553 780 ns/op 65.0 marshaledBytes
BenchmarkMarshalByXml-4 317310 3780 ns/op 137 marshaledBytes
BenchmarkMarshalByMsgp-4 10264906 109 ns/op 47.0 marshaledBytes
BenchmarkMarshalByProtoBuf-4 6027548 254 ns/op 36.0 marshaledBytes
BenchmarkMarshalByGogoProtoBuf-4 7823614 136 ns/op 36.0 marshaledBytes
BenchmarkMarshalByThrift-4 2713792 443 ns/op 63.0 marshaledBytes
BenchmarkMarshalByAvro-4 2710900 577 ns/op 32.0 marshaledBytes
BenchmarkMarshalByGencode-4 25360005 42.6 ns/op 34.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndCbor-4 736860 1488 ns/op 47.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndMsgp-4 927762 1474 ns/op 47.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndBinc-4 976227 1198 ns/op 47.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndJson-4 841494 1412 ns/op 65.0 marshaledBytes
BenchmarkMarshalByEasyjson-4 4410404 379 ns/op 65.0 marshaledBytes
BenchmarkMarshalByFfjson-4 1284018 968 ns/op 65.0 marshaledBytes
BenchmarkMarshalByJsoniter-4 2420109 678 ns/op 65.0 marshaledBytes
BenchmarkMarshalByGoMemdump-4 146306 8485 ns/op 200 marshaledBytes
BenchmarkMarshalByColfer-4 31515162 42.1 ns/op 35.0 marshaledBytes
BenchmarkMarshalByZebrapack-4 6037338 391 ns/op 109 marshaledBytes
BenchmarkMarshalByGotiny-4 3053563 526 ns/op 32.0 marshaledBytes
BenchmarkMarshalByHprose-4 2981386 351 ns/op 49.0 marshaledBytes
BenchmarkMarshalBySereal-4 454028 3649 ns/op 76.0 marshaledBytes
BenchmarkMarshalByVmihMsgpackv4-4 1531735 760 ns/op 55.0 marshaledBytes
BenchmarkMarshalByRlp-4 2019198 792 ns/op 32.0 marshaledBytes
BenchmarkMarshalBySegmentioJSON-4 1995334 1568 ns/op 65.0 marshaledBytes
```
**Unmarshal**
```
BenchmarkUnmarshalByJson-4 474681 2354 ns/op
BenchmarkUnmarshalByXml-4 93476 12787 ns/op
BenchmarkUnmarshalByMsgp-4 5169606 201 ns/op
BenchmarkUnmarshalByProtoBuf-4 2382018 507 ns/op
BenchmarkUnmarshalByGogoProtoBuf-4 2882487 413 ns/op
BenchmarkUnmarshalByThrift-4 1000000 1303 ns/op
BenchmarkUnmarshalByAvro-4 40338 26255 ns/op
BenchmarkUnmarshalByGencode-4 9043816 148 ns/op
BenchmarkUnmarshalByUgorjiCodecAndCbor-4 1339586 884 ns/op
BenchmarkUnmarshalByUgorjiCodecAndMsgp-4 1000000 1319 ns/op
BenchmarkUnmarshalByUgorjiCodecAndBinc-4 867388 1458 ns/op
BenchmarkUnmarshalByUgorjiCodecAndJson-4 1000000 1199 ns/op
BenchmarkUnmarshalByEasyjson-4 1929847 707 ns/op
BenchmarkUnmarshalByFfjson-4 844473 2286 ns/op
BenchmarkUnmarshalByJsoniter-4 1966244 808 ns/op
BenchmarkUnmarshalByGJSON-4 589440 2668 ns/op
BenchmarkUnmarshalByGoMemdump-4 844342 1500 ns/op
BenchmarkUnmarshalByColfer-4 5667135 247 ns/op
BenchmarkUnmarshalByZebrapack-4 3494541 323 ns/op
BenchmarkUnmarshalByGotiny-4 3546631 488 ns/op
BenchmarkUnmarshalByHprose-4 1779548 664 ns/op
BenchmarkUnmarshalBySereal-4 1714032 699 ns/op
BenchmarkUnmarshalByMsgpackv2-4 1000000 1731 ns/op
BenchmarkUnmarshalByRlp-4 1000000 1019 ns/op
BenchmarkUnmarshalBySegmentioJSON-4 1792550 663 ns/op
BenchmarkUnmarshalByJson-4 430582 3001 ns/op
BenchmarkUnmarshalByXml-4 86936 12710 ns/op
BenchmarkUnmarshalByMsgp-4 5982232 196 ns/op
BenchmarkUnmarshalByProtoBuf-4 2427032 573 ns/op
BenchmarkUnmarshalByGogoProtoBuf-4 2964386 393 ns/op
BenchmarkUnmarshalByThrift-4 872664 1147 ns/op
BenchmarkUnmarshalByAvro-4 53508 29774 ns/op
BenchmarkUnmarshalByGencode-4 9607225 123 ns/op
BenchmarkUnmarshalByUgorjiCodecAndCbor-4 682351 1526 ns/op
BenchmarkUnmarshalByUgorjiCodecAndMsgp-4 607396 1650 ns/op
BenchmarkUnmarshalByUgorjiCodecAndBinc-4 530145 2313 ns/op
BenchmarkUnmarshalByUgorjiCodecAndJson-4 445137 2759 ns/op
BenchmarkUnmarshalByEasyjson-4 2448640 588 ns/op
BenchmarkUnmarshalByFfjson-4 904053 1337 ns/op
BenchmarkUnmarshalByJsoniter-4 2127112 551 ns/op
BenchmarkUnmarshalByGJSON-4 578313 2776 ns/op
BenchmarkUnmarshalByGoMemdump-4 910186 1298 ns/op
BenchmarkUnmarshalByColfer-4 5520969 254 ns/op
BenchmarkUnmarshalByZebrapack-4 4125756 290 ns/op
BenchmarkUnmarshalByGotiny-4 3579372 333 ns/op
BenchmarkUnmarshalByHprose-4 1883326 816 ns/op
BenchmarkUnmarshalBySereal-4 1772971 673 ns/op
BenchmarkUnmarshalByVmihMsgpackv4-4 950239 1070 ns/op
BenchmarkUnmarshalByRlp-4 1000000 1221 ns/op
BenchmarkUnmarshalBySegmentioJSON-4 2093215 570 ns/op
```
7 changes: 1 addition & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ require (
github.com/golang/snappy v0.0.1 // indirect
github.com/hprose/hprose-golang v2.0.4+incompatible
github.com/json-iterator/go v1.1.7
github.com/kr/pretty v0.1.0 // indirect
github.com/mailru/easyjson v0.7.0
github.com/niubaoshu/gotiny v0.0.3
github.com/philhofer/fwd v1.0.0 // indirect
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7
github.com/sbinet/go-gnuplot v0.0.0-20130514120836-9167d8eb1ac4
github.com/segmentio/encoding v0.1.0
github.com/tidwall/gjson v1.3.2
github.com/tinylib/msgp v1.1.0
github.com/tinylib/msgp v1.1.1
github.com/ugorji/go/codec v1.1.7
github.com/vmihailenco/msgpack/v4 v4.3.0
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 // indirect
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c // indirect
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
)
19 changes: 4 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M=
github.com/sbinet/go-gnuplot v0.0.0-20130514120836-9167d8eb1ac4 h1:DjPYuV8FWDg57bkdJ2DQUB6PMQJUapXdJ1uCvPC7XT0=
github.com/sbinet/go-gnuplot v0.0.0-20130514120836-9167d8eb1ac4/go.mod h1:cBjaN6xLFdcYFeCkvNXnUCPPeHA23BR6Yg6liSwsLjE=
github.com/segmentio/encoding v0.1.0 h1:V/FrZFA2Fm4Hpk3JdA+3JWN6fJnp15dZOnB+CI3Wcbw=
github.com/segmentio/encoding v0.1.0/go.mod h1:RWhr02uzMB9gQC1x+MfYxedtmBibb9cZ6Vv9VxRSSbw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand All @@ -65,36 +63,27 @@ github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tinylib/msgp v1.1.0 h1:9fQd+ICuRIu/ue4vxJZu6/LzxN0HwMds2nq/0cFvxHU=
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
github.com/tinylib/msgp v1.1.1 h1:TnCZ3FIuKeaIy+F45+Cnp+caqdXGy4z74HvwXN+570Y=
github.com/tinylib/msgp v1.1.1/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack/v4 v4.3.0 h1:fevUjCdlnXAY0flxu7pPnoVcjZC2QlwJzC1xTgU/fvk=
github.com/vmihailenco/msgpack/v4 v4.3.0/go.mod h1:DuaveEe48abshDmz5UBKyZ+yDugvaeFk5ayfrewUOaw=
github.com/vmihailenco/msgpack/v4 v4.3.1 h1:9Ntwx2CBHXef6XQYkLfByWMwmQm5WspKAR6Xr+O5/ls=
github.com/vmihailenco/msgpack/v4 v4.3.1/go.mod h1:DuaveEe48abshDmz5UBKyZ+yDugvaeFk5ayfrewUOaw=
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b h1:mSUCVIwDx4hfXJfWsOPfdzEHxzb2Xjl6BQ8YgPnazQA=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
google.golang.org/appengine v1.6.2 h1:j8RI1yW0SkI+paT6uGwMlrMI/6zwYA6/CFil8rxOzGI=
google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
Expand Down
Loading

0 comments on commit e5b39b6

Please sign in to comment.