[#2061] meta: Add parallel bench for Get

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-11-15 19:17:53 +03:00 committed by fyrchik
parent 761e82fecd
commit bc905f169d

View file

@ -172,7 +172,7 @@ func BenchmarkGet(b *testing.B) {
}
for _, num := range numOfObjects {
b.Run(fmt.Sprintf("%d objects", num), func(b *testing.B) {
b.Run(fmt.Sprintf("%d_objects", num), func(b *testing.B) {
benchmarkGet(b, num)
})
}
@ -196,24 +196,37 @@ func benchmarkGet(b *testing.B, numOfObj int) {
_ = db.Close()
_ = os.RemoveAll(b.Name())
})
b.ReportAllocs()
b.ResetTimer()
var err error
var getPrm meta.GetPrm
getPrm.SetAddress(addrs[len(addrs)/2])
b.Run("parallel", func(b *testing.B) {
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_, err = db.Get(getPrm)
if err != nil {
b.Fatal(err)
}
}
})
})
b.Run("serial", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for _, addr := range addrs {
getPrm.SetAddress(addr)
res, err := db.Get(getPrm)
require.NoError(b, err)
obj = res.Header()
_, err := db.Get(getPrm)
if err != nil {
b.Fatal(err)
}
}
}
})
}
func metaGet(db *meta.DB, addr oid.Address, raw bool) (*objectSDK.Object, error) {
var prm meta.GetPrm