alecthomas/go_serialization_benchmarks — pull request #7 by sougou (2014-07-04 10:46:17+00:00)
Title: Use generated code for Vitess bson benchmarks.

The default vitess bson API uses reflection, which is slow. Vitess also
provides a code generator (bsongen), which I used to generate a custom
encoder/decoder.
I started off with this:
BenchmarkVitessBsonMarshal 100000 16843 ns/op
BenchmarkVitessBsonUnmarshal 500000 5185 ns/op

Reduced the default excessive buffer allocation from 16K to 1K:
BenchmarkVitessBsonMarshal 500000 4772 ns/op
BenchmarkVitessBsonUnmarshal 500000 5416 ns/op

Used generated code:
BenchmarkVitessBsonMarshal 1000000 2083 ns/op
BenchmarkVitessBsonUnmarshal 1000000 1158 ns/op

We'll work on reducing the default buffer size from 16K to 1K. It will
take us a few iterations to get there.

PS: Accept this CL only if you think it's fair, because other APIs don't use generated code.