diff options
author | Paulo Gomes <pjbgf@linux.com> | 2023-06-27 21:33:01 +0100 |
---|---|---|
committer | Paulo Gomes <pjbgf@linux.com> | 2023-10-28 03:51:33 +0100 |
commit | 814abc098d033f77315d3bfb89ae5991aae10457 (patch) | |
tree | 4f0baed9697e5423e7660b403d8263a84d317d5a /repository_test.go | |
parent | 6252084d6fd3173aceeecd6765722ae844ddb266 (diff) | |
download | go-git-814abc098d033f77315d3bfb89ae5991aae10457.tar.gz |
*: Improve BenchmarkPlainClone
The changes aim to make that specific benchmark more
reliable for setting a baseline which can later be
use to compare against future changes on the most
basic feature of go-git: plain cloning repositories.
Diffstat (limited to 'repository_test.go')
-rw-r--r-- | repository_test.go | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/repository_test.go b/repository_test.go index f6839b6..35a62f1 100644 --- a/repository_test.go +++ b/repository_test.go @@ -3311,20 +3311,25 @@ func BenchmarkObjects(b *testing.B) { } func BenchmarkPlainClone(b *testing.B) { - for i := 0; i < b.N; i++ { - t, err := os.MkdirTemp("", "") - if err != nil { - b.Fatal(err) - } - _, err = PlainClone(t, false, &CloneOptions{ - URL: "https://github.com/knqyf263/vuln-list", - Depth: 1, + b.StopTimer() + clone := func(b *testing.B) { + _, err := PlainClone(b.TempDir(), true, &CloneOptions{ + URL: "https://github.com/go-git/go-git.git", + Depth: 1, + Tags: NoTags, + SingleBranch: true, }) if err != nil { b.Error(err) } - b.StopTimer() - os.RemoveAll(t) - b.StartTimer() + } + + // Warm-up as the initial clone could have a higher cost which + // may skew results. + clone(b) + + b.StartTimer() + for i := 0; i < b.N; i++ { + clone(b) } } |