MCPcopy Create free account
hub / github.com/bufbuild/buf / BenchmarkBuildImage

Function BenchmarkBuildImage

private/bufpkg/bufimage/build_image_test.go:463–483  ·  view source on GitHub ↗

BenchmarkBuildImage builds an image from the googleapis corpus (1574 proto files), matching TestGoogleapis. Exercises the proto-source read path that allocates an io.Copy fallback buffer per file.

(b *testing.B)

Source from the content-addressed store, hash-verified

461// files), matching TestGoogleapis. Exercises the proto-source read path that
462// allocates an io.Copy fallback buffer per file.
463func BenchmarkBuildImage(b *testing.B) {
464 googleapisDirPath := buftesting.GetGoogleapisDirPath(b, buftestingDirPath)
465 moduleSet, err := bufmoduletesting.NewModuleSetForDirPath(googleapisDirPath)
466 if err != nil {
467 b.Fatal(err)
468 }
469 logger := slogtestext.NewLogger(b)
470 b.ResetTimer()
471 b.ReportAllocs()
472 for b.Loop() {
473 if _, err := bufimage.BuildImage(
474 b.Context(),
475 logger,
476 bufmodule.ModuleSetToModuleReadBucketWithOnlyProtoFiles(moduleSet),
477 bufimage.WithExcludeSourceCodeInfo(),
478 bufimage.WithNoParallelism(),
479 ); err != nil {
480 b.Fatal(err)
481 }
482 }
483}

Callers

nothing calls this directly

Calls 7

GetGoogleapisDirPathFunction · 0.92
NewModuleSetForDirPathFunction · 0.92
NewLoggerFunction · 0.92
BuildImageFunction · 0.92
WithNoParallelismFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…