aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go
index b78fbb7..e34627e 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -1688,3 +1688,59 @@ func (s *RepositorySuite) TestBrokenMultipleShallowFetch(c *C) {
})
c.Assert(err, IsNil)
}
+
+func BenchmarkObjects(b *testing.B) {
+ if err := fixtures.Init(); err != nil {
+ b.Fatal(err)
+ }
+
+ defer func() {
+ if err := fixtures.Clean(); err != nil {
+ b.Fatal(err)
+ }
+ }()
+
+ for _, f := range fixtures.ByTag("packfile") {
+ if f.DotGitHash == plumbing.ZeroHash {
+ continue
+ }
+
+ b.Run(f.URL, func(b *testing.B) {
+ fs := f.DotGit()
+ storer, err := filesystem.NewStorage(fs)
+ if err != nil {
+ b.Fatal(err)
+ }
+
+ worktree, err := fs.Chroot(filepath.Dir(fs.Root()))
+ if err != nil {
+ b.Fatal(err)
+ }
+
+ repo, err := Open(storer, worktree)
+ if err != nil {
+ b.Fatal(err)
+ }
+
+ for i := 0; i < b.N; i++ {
+ iter, err := repo.Objects()
+ if err != nil {
+ b.Fatal(err)
+ }
+
+ for {
+ _, err := iter.Next()
+ if err == io.EOF {
+ break
+ }
+
+ if err != nil {
+ b.Fatal(err)
+ }
+ }
+
+ iter.Close()
+ }
+ })
+ }
+}