aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-08-14 09:57:46 +0200
committerGitHub <noreply@github.com>2018-08-14 09:57:46 +0200
commita28c2ce44695f13ddf28748958f236afd8e0b544 (patch)
tree107dd441cd96b44b4f3994d26faf5f0bfae933fc /repository_test.go
parentc3740924da0d1929cb523c85ae9da3b456b901ea (diff)
parent8d75d239e93474e4287870e4e5143da14e2c360d (diff)
downloadgo-git-a28c2ce44695f13ddf28748958f236afd8e0b544.tar.gz
Merge pull request #906 from src-d/perf/packfile-reads
Improve packfile reading performance
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 7580878..261af7a 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -1714,3 +1714,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()
+ }
+ })
+ }
+}