aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/dotgit/dotgit_test.go
diff options
context:
space:
mode:
authorMiguel Molina <miguel@erizocosmi.co>2017-08-24 17:35:38 +0200
committerMiguel Molina <miguel@erizocosmi.co>2017-08-26 18:53:01 +0200
commit5a7b7af0f793b1c25e9543e8511b767f3b739d67 (patch)
treea6841928d57a89d440a6d5b0683501c40a15d82d /storage/filesystem/internal/dotgit/dotgit_test.go
parent6f3b2d878d2f84f513c9dc08b000f653ea83f690 (diff)
downloadgo-git-5a7b7af0f793b1c25e9543e8511b767f3b739d67.tar.gz
dotgit: rewrite the way references are looked up
Now there's only two ways of getting a reference, by checking under refs/ directory or in packed-refs. refs/ directory is checked using a direct read by reference name and packed refs are cached until they have been changed. Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
Diffstat (limited to 'storage/filesystem/internal/dotgit/dotgit_test.go')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go
index d935ec5..a7f16f4 100644
--- a/storage/filesystem/internal/dotgit/dotgit_test.go
+++ b/storage/filesystem/internal/dotgit/dotgit_test.go
@@ -134,6 +134,24 @@ func (s *SuiteDotGit) TestRefsFromReferenceFile(c *C) {
}
+func BenchmarkRefMultipleTimes(b *testing.B) {
+ fs := fixtures.Basic().ByTag(".git").One().DotGit()
+ refname := plumbing.ReferenceName("refs/remotes/origin/branch")
+
+ dir := New(fs)
+ _, err := dir.Ref(refname)
+ if err != nil {
+ b.Fatalf("unexpected error: %s", err)
+ }
+
+ for i := 0; i < b.N; i++ {
+ _, err := dir.Ref(refname)
+ if err != nil {
+ b.Fatalf("unexpected error: %s", err)
+ }
+ }
+}
+
func (s *SuiteDotGit) TestRemoveRefFromReferenceFile(c *C) {
fs := fixtures.Basic().ByTag(".git").One().DotGit()
dir := New(fs)