aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/reference_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2022-11-07 16:53:56 +0100
committerGitHub <noreply@github.com>2022-11-07 16:53:56 +0100
commit652bc83fe45c114440de41d7e0fecf3e4b9e517d (patch)
treea784f0a4b677abc00247638e600f5efef1c44dfc /plumbing/reference_test.go
parent08cffa1efade914020497a73907763e8d3707a77 (diff)
parentffa7e69efb8c4ba8d4e08ec4c65e49e2228fd88b (diff)
downloadgo-git-652bc83fe45c114440de41d7e0fecf3e4b9e517d.tar.gz
Merge pull request #602 from pjbgf/parse-optimisation
Parse optimisations
Diffstat (limited to 'plumbing/reference_test.go')
-rw-r--r--plumbing/reference_test.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/plumbing/reference_test.go b/plumbing/reference_test.go
index b3ccf53..e69076f 100644
--- a/plumbing/reference_test.go
+++ b/plumbing/reference_test.go
@@ -1,6 +1,10 @@
package plumbing
-import . "gopkg.in/check.v1"
+import (
+ "testing"
+
+ . "gopkg.in/check.v1"
+)
type ReferenceSuite struct{}
@@ -98,3 +102,21 @@ func (s *ReferenceSuite) TestIsTag(c *C) {
r := ReferenceName("refs/tags/v3.1.")
c.Assert(r.IsTag(), Equals, true)
}
+
+func benchMarkReferenceString(r *Reference, b *testing.B) {
+ for n := 0; n < b.N; n++ {
+ r.String()
+ }
+}
+
+func BenchmarkReferenceStringSymbolic(b *testing.B) {
+ benchMarkReferenceString(NewSymbolicReference("v3.1.1", "refs/tags/v3.1.1"), b)
+}
+
+func BenchmarkReferenceStringHash(b *testing.B) {
+ benchMarkReferenceString(NewHashReference("v3.1.1", NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")), b)
+}
+
+func BenchmarkReferenceStringInvalid(b *testing.B) {
+ benchMarkReferenceString(&Reference{}, b)
+}