Small fixes for local blobstor benchmarks #236

Merged
fyrchik merged 1 commit from fyrchik/frostfs-node:perf-test-fix into master 2023-07-26 21:07:57 +00:00

View file

@ -11,6 +11,7 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/memstore" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/memstore"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
) )
type storage struct { type storage struct {
@ -103,18 +104,23 @@ func BenchmarkSubstorageReadPerf(b *testing.B) {
st := stEntry.open(b) st := stEntry.open(b)
// Fill database // Fill database
var errG errgroup.Group
for i := 0; i < tt.size; i++ { for i := 0; i < tt.size; i++ {
obj := objGen.Next() obj := objGen.Next()
addr := testutil.AddressFromObject(b, obj) addr := testutil.AddressFromObject(b, obj)
errG.Go(func() error {
raw, err := obj.Marshal() raw, err := obj.Marshal()
require.NoError(b, err) if err != nil {
if _, err := st.Put(common.PutPrm{ return fmt.Errorf("marshal: %v", err)
}
_, err = st.Put(common.PutPrm{
Address: addr, Address: addr,
RawData: raw, RawData: raw,
}); err != nil { })
b.Fatalf("writing entry: %v", err) return err
} })
} }
require.NoError(b, errG.Wait())
// Benchmark reading // Benchmark reading
addrGen := tt.addrGen() addrGen := tt.addrGen()