diff options
author | Paulo Gomes <pjbgf@linux.com> | 2022-10-26 18:12:39 +0100 |
---|---|---|
committer | Paulo Gomes <pjbgf@linux.com> | 2022-11-07 14:41:07 +0000 |
commit | 123cdde6f2f6282cb779e03745d384833ac1265b (patch) | |
tree | dc20c37ece501c3d66935c3832269393f2c18f63 /plumbing/format/packfile/parser_test.go | |
parent | 08cffa1efade914020497a73907763e8d3707a77 (diff) | |
download | go-git-123cdde6f2f6282cb779e03745d384833ac1265b.tar.gz |
Use Sync.Pool pointers to optimise memory usage
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
Diffstat (limited to 'plumbing/format/packfile/parser_test.go')
-rw-r--r-- | plumbing/format/packfile/parser_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/plumbing/format/packfile/parser_test.go b/plumbing/format/packfile/parser_test.go index 09f3f97..651d05f 100644 --- a/plumbing/format/packfile/parser_test.go +++ b/plumbing/format/packfile/parser_test.go @@ -10,8 +10,10 @@ import ( fixtures "github.com/go-git/go-git-fixtures/v4" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" + "github.com/go-git/go-git/v5/plumbing/cache" "github.com/go-git/go-git/v5/plumbing/format/packfile" "github.com/go-git/go-git/v5/plumbing/storer" + "github.com/go-git/go-git/v5/storage/filesystem" . "gopkg.in/check.v1" ) @@ -248,3 +250,29 @@ func BenchmarkParseBasic(b *testing.B) { } } } + +func BenchmarkParser(b *testing.B) { + f := fixtures.Basic().One() + defer fixtures.Clean() + + b.ResetTimer() + for n := 0; n < b.N; n++ { + b.StopTimer() + scanner := packfile.NewScanner(f.Packfile()) + fs := osfs.New(os.TempDir()) + storage := filesystem.NewStorage(fs, cache.NewObjectLRUDefault()) + + parser, err := packfile.NewParserWithStorage(scanner, storage) + if err != nil { + b.Error(err) + } + + b.StartTimer() + _, err = parser.Parse() + + b.StopTimer() + if err != nil { + b.Error(err) + } + } +} |