Generate sizer functions for oneofs.
This improves oneof sizing performance by ~9x.
func BenchmarkSizeTrivial(b *testing.B) {
benchmarkSize(b, &MyMessage{Count: Int32(0)})
}
func BenchmarkSizeOneof(b *testing.B) {
benchmarkSize(b, &Communique{Union: &Communique_Number{0}})
}
Without this change:
BenchmarkSizeTrivial-12 5000000 355 ns/op
BenchmarkSizeOneof-12 500000 2754 ns/op
With this change:
BenchmarkSizeTrivial-12 5000000 336 ns/op
BenchmarkSizeOneof-12 5000000 306 ns/op
Signed-off-by: David Symonds <dsymonds@golang.org>
9 files changed