Export changes from Google-internal version:
- faster text parsing
- use numbers instead of repeated Xs for package import name conflict resolution
R=r
CC=golang-dev
http://codereview.appspot.com/2540041
diff --git a/proto/text_parser_test.go b/proto/text_parser_test.go
index 5382ac5..a31bd43 100644
--- a/proto/text_parser_test.go
+++ b/proto/text_parser_test.go
@@ -256,3 +256,27 @@
}
}
}
+
+var benchInput string
+
+func init() {
+ benchInput = "count: 4\n"
+ for i := 0; i < 1000; i++ {
+ benchInput += "pet: \"fido\"\n"
+ }
+
+ // Check it is valid input.
+ pb := new(MyMessage)
+ err := UnmarshalText(benchInput, pb)
+ if err != nil {
+ panic("Bad benchmark input: " + err.String())
+ }
+}
+
+func BenchmarkUnmarshalText(b *testing.B) {
+ pb := new(MyMessage)
+ for i := 0; i < b.N; i++ {
+ UnmarshalText(benchInput, pb)
+ }
+ b.SetBytes(int64(len(benchInput)))
+}