forked from TrueCloudLab/frostfs-node
[#1450] engine: Add benchmark for Inhume
operation
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
748edd1999
commit
b348b20289
1 changed files with 60 additions and 0 deletions
|
@ -2,6 +2,7 @@ package engine
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
|
@ -12,8 +13,11 @@ import (
|
|||
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/object"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
objecttest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func TestStorageEngine_Inhume(t *testing.T) {
|
||||
|
@ -137,3 +141,59 @@ func TestInhumeExpiredRegularObject(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkInhumeMultipart(b *testing.B) {
|
||||
// The benchmark result insignificantly depends on the number of shards,
|
||||
// so do not use it as a benchmark parameter, just set it big enough.
|
||||
numShards := 100
|
||||
|
||||
for numObjects := 1; numObjects <= 10000; numObjects *= 10 {
|
||||
b.Run(
|
||||
fmt.Sprintf("objects=%d", numObjects),
|
||||
func(b *testing.B) {
|
||||
benchmarkInhumeMultipart(b, numShards, numObjects)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func benchmarkInhumeMultipart(b *testing.B, numShards, numObjects int) {
|
||||
b.StopTimer()
|
||||
|
||||
engine := testNewEngine(b, WithShardPoolSize(uint32(numObjects))).
|
||||
setShardsNum(b, numShards).prepare(b).engine
|
||||
defer func() { require.NoError(b, engine.Close(context.Background())) }()
|
||||
|
||||
cnt := cidtest.ID()
|
||||
eg := errgroup.Group{}
|
||||
|
||||
for range b.N {
|
||||
addrs := make([]oid.Address, numObjects)
|
||||
|
||||
for i := range numObjects {
|
||||
prm := PutPrm{}
|
||||
|
||||
prm.Object = objecttest.Object().Parent()
|
||||
prm.Object.SetContainerID(cnt)
|
||||
prm.Object.SetType(objectSDK.TypeRegular)
|
||||
|
||||
addrs[i] = object.AddressOf(prm.Object)
|
||||
|
||||
eg.Go(func() error {
|
||||
return engine.Put(context.Background(), prm)
|
||||
})
|
||||
}
|
||||
require.NoError(b, eg.Wait())
|
||||
|
||||
ts := oidtest.Address()
|
||||
ts.SetContainer(cnt)
|
||||
|
||||
prm := InhumePrm{}
|
||||
prm.WithTarget(ts, addrs...)
|
||||
|
||||
b.StartTimer()
|
||||
_, err := engine.Inhume(context.Background(), prm)
|
||||
require.NoError(b, err)
|
||||
b.StopTimer()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue