aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile
diff options
context:
space:
mode:
authorMiguel Molina <miguel@erizocosmi.co>2018-08-09 09:23:44 +0200
committerMiguel Molina <miguel@erizocosmi.co>2018-08-09 09:23:44 +0200
commitb3d995f5ca6b544ed8a48fced85ffa94600af302 (patch)
treeb19acdebe271f6c75ef39a1f28fc13f282ed2e44 /plumbing/format/packfile
parent5889a3b669f0f515ff445aa040afc1e7eeb2bbd1 (diff)
downloadgo-git-b3d995f5ca6b544ed8a48fced85ffa94600af302.tar.gz
plumbing: packfile, add Parse benchmark
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
Diffstat (limited to 'plumbing/format/packfile')
-rw-r--r--plumbing/format/packfile/parser_test.go30
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)
+ }
+ }
+ })
+ }
+}