Add benchmarks
diff --git a/pointer_test.go b/pointer_test.go
index 86114ce..9e66d51 100644
--- a/pointer_test.go
+++ b/pointer_test.go
@@ -84,6 +84,34 @@
}
+func BenchmarkParse(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ NewJsonPointer(`/definitions/simple/0/next`)
+ }
+}
+
+func BenchmarkParseWithEscape(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ NewJsonPointer(`/definiti~0ons/simple/0/next`)
+ }
+}
+
+func BenchmarkString(b *testing.B) {
+ p, _ := NewJsonPointer(`/definitions/simple/0/next`)
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ p.String()
+ }
+}
+
+func BenchmarkStringWithEscape(b *testing.B) {
+ p, _ := NewJsonPointer(`/definiti~0ons/simple/0/next`)
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ p.String()
+ }
+}
+
func TestFullDocument(t *testing.T) {
in := ``
@@ -122,6 +150,14 @@
}
}
+func BenchmarkGet(b *testing.B) {
+ p, _ := NewJsonPointer(`/obj/d/1/f`)
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ p.Get(testDocumentJson)
+ }
+}
+
func TestArray(t *testing.T) {
ins := []string{`/foo/0`, `/foo/0`, `/foo/1`}