Permalink
Browse files

Add benchmark for decoding simple structs

  • Loading branch information...
1 parent b21d962 commit cab73343609ad7ec9bf99e315059163337b40457 @samuel committed Aug 14, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 encoder_test.go
View
17 encoder_test.go
@@ -223,3 +223,20 @@ func BenchmarkEncodeSimpleStruct(b *testing.B) {
EncodeStruct(buf, BinaryProtocol, st)
}
}
+
+func BenchmarkDecodeSimpleStruct(b *testing.B) {
+ b.StopTimer()
+ buf1 := &bytes.Buffer{}
+ st := &struct {
+ Str string `thrift:"1,required"`
+ Int int32 `thrift:"2,required"`
+ }{
+ Str: "test",
+ Int: 123,
+ }
+ buf := bytes.NewBuffer(bytes.Repeat(buf1.Bytes(), b.N))
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ DecodeStruct(buf, BinaryProtocol, st)
+ }
+}

0 comments on commit cab7334

Please sign in to comment.