diff options
author | Miguel Molina <miguel@erizocosmi.co> | 2018-08-09 09:23:44 +0200 |
---|---|---|
committer | Miguel Molina <miguel@erizocosmi.co> | 2018-08-09 09:23:44 +0200 |
commit | b3d995f5ca6b544ed8a48fced85ffa94600af302 (patch) | |
tree | b19acdebe271f6c75ef39a1f28fc13f282ed2e44 | |
parent | 5889a3b669f0f515ff445aa040afc1e7eeb2bbd1 (diff) | |
download | go-git-b3d995f5ca6b544ed8a48fced85ffa94600af302.tar.gz |
plumbing: packfile, add Parse benchmark
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
-rw-r--r-- | plumbing/format/packfile/parser_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/plumbing/format/packfile/parser_test.go b/plumbing/format/packfile/parser_test.go index 7bce737..b5d482e 100644 --- a/plumbing/format/packfile/parser_test.go +++ b/plumbing/format/packfile/parser_test.go @@ -1,6 +1,8 @@ package packfile_test import ( + "testing" + "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/plumbing/format/packfile" @@ -138,3 +140,31 @@ func (t *testObserver) put(pos int64, o observerObject) { t.pos[pos] = len(t.objects) t.objects = append(t.objects, o) } + +func BenchmarkParse(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") { + b.Run(f.URL, func(b *testing.B) { + for i := 0; i < b.N; i++ { + parser, err := packfile.NewParser(packfile.NewScanner(f.Packfile())) + if err != nil { + b.Fatal(err) + } + + _, err = parser.Parse() + if err != nil { + b.Fatal(err) + } + } + }) + } +} |