MCPcopy Create free account
hub / github.com/go-git/go-git / BenchmarkObjects

Function BenchmarkObjects

repository_test.go:3412–3455  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

3410}
3411
3412func BenchmarkObjects(b *testing.B) {
3413 defer fixtures.Clean()
3414
3415 for _, f := range fixtures.ByTag("packfile") {
3416 if f.DotGitHash == "" {
3417 continue
3418 }
3419
3420 b.Run(f.URL, func(b *testing.B) {
3421 fs := f.DotGit()
3422 st := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
3423
3424 worktree, err := fs.Chroot(filepath.Dir(fs.Root()))
3425 if err != nil {
3426 b.Fatal(err)
3427 }
3428
3429 repo, err := Open(st, worktree)
3430 if err != nil {
3431 b.Fatal(err)
3432 }
3433
3434 for i := 0; i < b.N; i++ {
3435 iter, err := repo.Objects()
3436 if err != nil {
3437 b.Fatal(err)
3438 }
3439
3440 for {
3441 _, err := iter.Next()
3442 if err == io.EOF {
3443 break
3444 }
3445
3446 if err != nil {
3447 b.Fatal(err)
3448 }
3449 }
3450
3451 iter.Close()
3452 }
3453 })
3454 }
3455}
3456
3457func BenchmarkPlainClone(b *testing.B) {
3458 b.StopTimer()

Callers

nothing calls this directly

Calls 9

NewStorageFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
OpenFunction · 0.85
CleanMethod · 0.80
ChrootMethod · 0.80
RootMethod · 0.80
NextMethod · 0.65
CloseMethod · 0.65
ObjectsMethod · 0.45

Tested by

no test coverage detected