Skip to content

Commit 0c64f1e

Browse files
committed
New benchmark results.
See alecthomas#49.
1 parent 0ed6899 commit 0c64f1e

8 files changed

+88
-526
lines changed

Makefile

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
all: FlatBufferA.go msgp_gen.go structdef-gogo.pb.go structdef.pb.go vitess_test.go structdef.capnp.go structdef.capnp2.go gencode.schema.gen.go
1+
# This is necessary due to the use of two conflicting generator commands for capnproto
2+
.NOTPARALLEL:
3+
4+
all: FlatBufferA.go msgp_gen.go structdef-gogo.pb.go structdef.pb.go structdef.capnp.go structdef.capnp2.go gencode.schema.gen.go gencode-unsafe.schema.gen.go
25

36
FlatBufferA.go: flatbuffers-structdef.fbs
47
flatc -g flatbuffers-structdef.fbs
@@ -10,17 +13,14 @@ msgp_gen.go: structdef.go
1013
go generate
1114

1215
structdef_easyjson.go: structdef.go
13-
easyjson -all structdef.go
16+
easyjson -all structdef.go
1417

1518
structdef-gogo.pb.go: structdef-gogo.proto
1619
protoc --gogofaster_out=. -I. -I${GOPATH}/src -I${GOPATH}/src/github.com/gogo/protobuf/protobuf structdef-gogo.proto
1720

1821
structdef.pb.go: structdef.proto
1922
protoc --go_out=. structdef.proto
2023

21-
vitess_test.go: structdef.go
22-
bsongen -file=structdef.go -o=vitess_test.go -type=A
23-
2424
structdef.capnp2.go: structdef.capnp2
2525
go get -u zombiezen.com/go/capnproto2/... # conflicts with go-capnproto
2626
capnp compile -I${GOPATH}/src -ogo structdef.capnp2
@@ -37,17 +37,16 @@ gencode-unsafe.schema.gen.go: gencode-unsafe.schema
3737

3838
.PHONY: clean
3939
clean:
40-
rm -f FlatBufferA.go msgp_gen.go structdef-gogo.pb.go structdef.pb.go vitess_test.go structdef.capnp.go structdef.capnp2.go gencode.schema.gen.go gencode-unsafe.schema.gen.go
40+
rm -f FlatBufferA.go msgp_gen.go structdef-gogo.pb.go structdef.pb.go structdef.capnp.go structdef.capnp2.go gencode.schema.gen.go gencode-unsafe.schema.gen.go
4141

4242
.PHONY: install
4343
install:
4444
go get -u github.com/gogo/protobuf/protoc-gen-gogofaster
4545
go get -u github.com/gogo/protobuf/gogoproto
4646
go get -u github.com/golang/protobuf/protoc-gen-go
4747
go get -u github.com/tinylib/msgp
48-
# go get -u github.com/andyleap/gencode
48+
go get -u github.com/andyleap/gencode
4949
go get -u github.com/mailru/easyjson/...
50-
5150
go get -u github.com/DeDiS/protobuf
5251
go get -u github.com/Sereal/Sereal/Go/sereal
5352
go get -u github.com/alecthomas/binary

README.md

+40-38
Original file line numberDiff line numberDiff line change
@@ -67,44 +67,46 @@ Results with Go 1.6 on a 3.1 GHz Intel Core i7 (MacBook Pro (Retina, 13-inch, Ea
6767
```
6868
benchmark iter time/iter bytes alloc allocs
6969
--------- ---- --------- ----------- ------
70-
BenchmarkMsgpMarshal-4 5000000 274 ns/op 128 B/op 1 allocs/op
71-
BenchmarkMsgpUnmarshal-4 3000000 493 ns/op 112 B/op 3 allocs/op
72-
BenchmarkVmihailencoMsgpackMarshal-4 1000000 1681 ns/op 352 B/op 5 allocs/op
73-
BenchmarkVmihailencoMsgpackUnmarshal-4 1000000 2120 ns/op 352 B/op 13 allocs/op
74-
BenchmarkJsonMarshal-4 500000 3498 ns/op 1232 B/op 10 allocs/op
75-
BenchmarkJsonUnmarshal-4 500000 3596 ns/op 415 B/op 7 allocs/op
76-
BenchmarkEasyJsonMarshal-4 1000000 1715 ns/op 784 B/op 5 allocs/op
77-
BenchmarkEasyJsonUnmarshal-4 1000000 1585 ns/op 160 B/op 4 allocs/op
78-
BenchmarkBsonMarshal-4 1000000 1816 ns/op 392 B/op 10 allocs/op
79-
BenchmarkBsonUnmarshal-4 1000000 2352 ns/op 248 B/op 21 allocs/op
80-
BenchmarkGobMarshal-4 1000000 1174 ns/op 48 B/op 2 allocs/op
81-
BenchmarkGobUnmarshal-4 1000000 1147 ns/op 112 B/op 3 allocs/op
82-
BenchmarkXdrMarshal-4 1000000 2231 ns/op 455 B/op 20 allocs/op
83-
BenchmarkXdrUnmarshal-4 1000000 1740 ns/op 239 B/op 11 allocs/op
84-
BenchmarkUgorjiCodecMsgpackMarshal-4 500000 3103 ns/op 2753 B/op 8 allocs/op
85-
BenchmarkUgorjiCodecMsgpackUnmarshal-4 500000 3341 ns/op 3008 B/op 6 allocs/op
86-
BenchmarkUgorjiCodecBincMarshal-4 500000 3156 ns/op 2785 B/op 8 allocs/op
87-
BenchmarkUgorjiCodecBincUnmarshal-4 500000 3601 ns/op 3168 B/op 9 allocs/op
88-
BenchmarkSerealMarshal-4 300000 4171 ns/op 912 B/op 21 allocs/op
89-
BenchmarkSerealUnmarshal-4 500000 3738 ns/op 1008 B/op 34 allocs/op
90-
BenchmarkBinaryMarshal-4 1000000 1738 ns/op 256 B/op 16 allocs/op
91-
BenchmarkBinaryUnmarshal-4 1000000 1867 ns/op 336 B/op 22 allocs/op
92-
BenchmarkFlatbuffersMarshal-4 5000000 389 ns/op 0 B/op 0 allocs/op
93-
BenchmarkFlatBuffersUnmarshal-4 5000000 345 ns/op 112 B/op 3 allocs/op
94-
BenchmarkCapNProtoMarshal-4 3000000 553 ns/op 56 B/op 2 allocs/op
95-
BenchmarkCapNProtoUnmarshal-4 3000000 514 ns/op 216 B/op 6 allocs/op
96-
BenchmarkCapNProto2Marshal-4 1000000 1358 ns/op 436 B/op 12 allocs/op
97-
BenchmarkCapNProto2Unmarshal-4 1000000 1165 ns/op 464 B/op 12 allocs/op
98-
BenchmarkHproseMarshal-4 1000000 1183 ns/op 478 B/op 8 allocs/op
99-
BenchmarkHproseUnmarshal-4 1000000 1433 ns/op 320 B/op 10 allocs/op
100-
BenchmarkProtobufMarshal-4 1000000 1264 ns/op 200 B/op 7 allocs/op
101-
BenchmarkProtobufUnmarshal-4 2000000 974 ns/op 192 B/op 10 allocs/op
102-
BenchmarkGoprotobufMarshal-4 2000000 743 ns/op 312 B/op 4 allocs/op
103-
BenchmarkGoprotobufUnmarshal-4 1000000 1006 ns/op 432 B/op 9 allocs/op
104-
BenchmarkGogoprotobufMarshal-4 10000000 212 ns/op 64 B/op 1 allocs/op
105-
BenchmarkGogoprotobufUnmarshal-4 5000000 296 ns/op 96 B/op 3 allocs/op
106-
BenchmarkGencodeMarshal-4 10000000 216 ns/op 80 B/op 2 allocs/op
107-
BenchmarkGencodeUnmarshal-4 5000000 257 ns/op 112 B/op 3 allocs/op
70+
BenchmarkMsgpMarshal-8 5000000 247 ns/op 128 B/op 1 allocs/op
71+
BenchmarkMsgpUnmarshal-8 3000000 440 ns/op 112 B/op 3 allocs/op
72+
BenchmarkVmihailencoMsgpackMarshal-8 1000000 1670 ns/op 352 B/op 5 allocs/op
73+
BenchmarkVmihailencoMsgpackUnmarshal-8 1000000 1866 ns/op 352 B/op 13 allocs/op
74+
BenchmarkJsonMarshal-8 500000 3216 ns/op 1232 B/op 10 allocs/op
75+
BenchmarkJsonUnmarshal-8 500000 3305 ns/op 416 B/op 7 allocs/op
76+
BenchmarkEasyJsonMarshal-8 1000000 1644 ns/op 784 B/op 5 allocs/op
77+
BenchmarkEasyJsonUnmarshal-8 1000000 1431 ns/op 160 B/op 4 allocs/op
78+
BenchmarkBsonMarshal-8 1000000 1642 ns/op 392 B/op 10 allocs/op
79+
BenchmarkBsonUnmarshal-8 1000000 2221 ns/op 248 B/op 21 allocs/op
80+
BenchmarkGobMarshal-8 1000000 1105 ns/op 48 B/op 2 allocs/op
81+
BenchmarkGobUnmarshal-8 1000000 1075 ns/op 112 B/op 3 allocs/op
82+
BenchmarkXdrMarshal-8 1000000 2178 ns/op 455 B/op 21 allocs/op
83+
BenchmarkXdrUnmarshal-8 1000000 1585 ns/op 240 B/op 11 allocs/op
84+
BenchmarkUgorjiCodecMsgpackMarshal-8 500000 2969 ns/op 2753 B/op 8 allocs/op
85+
BenchmarkUgorjiCodecMsgpackUnmarshal-8 500000 3082 ns/op 3008 B/op 6 allocs/op
86+
BenchmarkUgorjiCodecBincMarshal-8 500000 2908 ns/op 2785 B/op 8 allocs/op
87+
BenchmarkUgorjiCodecBincUnmarshal-8 500000 3266 ns/op 3168 B/op 9 allocs/op
88+
BenchmarkSerealMarshal-8 500000 4012 ns/op 912 B/op 21 allocs/op
89+
BenchmarkSerealUnmarshal-8 500000 3567 ns/op 1008 B/op 34 allocs/op
90+
BenchmarkBinaryMarshal-8 1000000 1578 ns/op 256 B/op 16 allocs/op
91+
BenchmarkBinaryUnmarshal-8 1000000 1675 ns/op 336 B/op 22 allocs/op
92+
BenchmarkFlatbuffersMarshal-8 5000000 361 ns/op 0 B/op 0 allocs/op
93+
BenchmarkFlatBuffersUnmarshal-8 5000000 312 ns/op 112 B/op 3 allocs/op
94+
BenchmarkCapNProtoMarshal-8 3000000 502 ns/op 56 B/op 2 allocs/op
95+
BenchmarkCapNProtoUnmarshal-8 3000000 465 ns/op 200 B/op 6 allocs/op
96+
BenchmarkCapNProto2Marshal-8 1000000 1247 ns/op 244 B/op 3 allocs/op
97+
BenchmarkCapNProto2Unmarshal-8 1000000 1187 ns/op 320 B/op 6 allocs/op
98+
BenchmarkHproseMarshal-8 1000000 1083 ns/op 473 B/op 8 allocs/op
99+
BenchmarkHproseUnmarshal-8 1000000 1324 ns/op 320 B/op 10 allocs/op
100+
BenchmarkProtobufMarshal-8 1000000 1292 ns/op 200 B/op 7 allocs/op
101+
BenchmarkProtobufUnmarshal-8 1000000 1034 ns/op 192 B/op 10 allocs/op
102+
BenchmarkGoprotobufMarshal-8 2000000 681 ns/op 312 B/op 4 allocs/op
103+
BenchmarkGoprotobufUnmarshal-8 2000000 901 ns/op 432 B/op 9 allocs/op
104+
BenchmarkGogoprotobufMarshal-8 10000000 198 ns/op 64 B/op 1 allocs/op
105+
BenchmarkGogoprotobufUnmarshal-8 5000000 286 ns/op 96 B/op 3 allocs/op
106+
BenchmarkGencodeMarshal-8 10000000 191 ns/op 80 B/op 2 allocs/op
107+
BenchmarkGencodeUnmarshal-8 10000000 231 ns/op 112 B/op 3 allocs/op
108+
BenchmarkGencodeUnsafeMarshal-8 10000000 120 ns/op 48 B/op 1 allocs/op
109+
BenchmarkGencodeUnsafeUnmarshal-8 10000000 180 ns/op 96 B/op 3 allocs/op
108110
```
109111

110112
## Issues

gencode-unsafe.schema.gen.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (d *GencodeUnsafeA) Marshal(buf []byte) ([]byte, error) {
102102
}
103103
{
104104

105-
d.BirthDay = *(*int64)(unsafe.Pointer(&buf[i+0]))
105+
*(*int64)(unsafe.Pointer(&buf[i+0])) = d.BirthDay
106106

107107
}
108108
{

msgp_gen.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ package goserbench
44
// MSGP CODE GENERATION TOOL (github.com/tinylib/msgp)
55
// DO NOT EDIT
66

7-
import (
8-
"github.com/tinylib/msgp/msgp"
9-
)
7+
import "github.com/tinylib/msgp/msgp"
108

119
// MarshalMsg implements msgp.Marshaler
1210
func (z *A) MarshalMsg(b []byte) (o []byte, err error) {
@@ -37,13 +35,13 @@ func (z *A) MarshalMsg(b []byte) (o []byte, err error) {
3735
func (z *A) UnmarshalMsg(bts []byte) (o []byte, err error) {
3836
var field []byte
3937
_ = field
40-
var isz uint32
41-
isz, bts, err = msgp.ReadMapHeaderBytes(bts)
38+
var xvk uint32
39+
xvk, bts, err = msgp.ReadMapHeaderBytes(bts)
4240
if err != nil {
4341
return
4442
}
45-
for isz > 0 {
46-
isz--
43+
for xvk > 0 {
44+
xvk--
4745
field, bts, err = msgp.ReadMapKeyZC(bts)
4846
if err != nil {
4947
return

serialization_benchmarks_test.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ func BenchmarkVmihailencoMsgpackUnmarshal(b *testing.B) {
185185

186186
type JsonSerializer struct{}
187187

188-
func (m JsonSerializer) Marshal(o interface{}) []byte {
188+
func (j JsonSerializer) Marshal(o interface{}) []byte {
189189
d, _ := json.Marshal(o)
190190
return d
191191
}
192192

193-
func (m JsonSerializer) Unmarshal(d []byte, o interface{}) error {
193+
func (j JsonSerializer) Unmarshal(d []byte, o interface{}) error {
194194
return json.Unmarshal(d, o)
195195
}
196196

@@ -208,26 +208,26 @@ func BenchmarkJsonUnmarshal(b *testing.B) {
208208

209209
// github.com/mailru/easyjson
210210

211-
type EasyJsonSerializer struct{}
211+
type EasyJSONSerializer struct{}
212212

213-
func (m EasyJsonSerializer) Marshal(o interface{}) []byte {
213+
func (m EasyJSONSerializer) Marshal(o interface{}) []byte {
214214
out, _ := o.(*A).MarshalJSON()
215215
return out
216216
}
217217

218-
func (m EasyJsonSerializer) Unmarshal(d []byte, o interface{}) error {
218+
func (m EasyJSONSerializer) Unmarshal(d []byte, o interface{}) error {
219219
err := o.(*A).UnmarshalJSON(d)
220220
return err
221221
}
222222

223-
func (m EasyJsonSerializer) String() string { return "EasyJson" }
223+
func (m EasyJSONSerializer) String() string { return "EasyJson" }
224224

225225
func BenchmarkEasyJsonMarshal(b *testing.B) {
226-
benchMarshal(b, EasyJsonSerializer{})
226+
benchMarshal(b, EasyJSONSerializer{})
227227
}
228228

229229
func BenchmarkEasyJsonUnmarshal(b *testing.B) {
230-
benchUnmarshal(b, EasyJsonSerializer{})
230+
benchUnmarshal(b, EasyJSONSerializer{})
231231
}
232232

233233
// gopkg.in/mgo.v2/bson
@@ -651,7 +651,7 @@ func (m ProtobufSerializer) Unmarshal(d []byte, o interface{}) error {
651651
return protobuf.Decode(d, o)
652652
}
653653

654-
func (j ProtobufSerializer) String() string {
654+
func (m ProtobufSerializer) String() string {
655655
return "protobuf"
656656
}
657657

structdef-gogo.pb.go

+26-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)