forked from TrueCloudLab/frostfs-node
Evgenii Stratonikov
1f4061c0e2
The real reason is this: ``` pkg/local_object_storage/blobovnicza/sizes.go:36:69 revive empty-block: this block is empty, you can remove it ``` Didn't want to make this function longer or to add `nolint`, thus this change. To justify: ``` UpperBound/size=1-8 0.4924n ± 1% 0.2472n ± 2% -49.80% (p=0.000 n=10) UpperBound/size=1023-8 0.4936n ± 3% 0.2442n ± 1% -50.52% (p=0.000 n=10) UpperBound/size=66560-8 0.8201n ± 2% 0.2436n ± 1% -70.29% (p=0.000 n=10) UpperBound/size=41943040-8 6.6900n ± 5% 0.2432n ± 0% -96.36% (p=0.000 n=10) geomean 1.075n 0.2446n -77.24% ``` Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
49 lines
964 B
Go
49 lines
964 B
Go
package blobovnicza
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSizes(t *testing.T) {
|
|
for _, item := range []struct {
|
|
sz uint64 // object size
|
|
|
|
upperBound uint64 // upper bound of expected range
|
|
}{
|
|
{
|
|
sz: 0,
|
|
upperBound: firstBucketBound,
|
|
},
|
|
{
|
|
sz: firstBucketBound,
|
|
upperBound: firstBucketBound,
|
|
},
|
|
{
|
|
sz: firstBucketBound + 1,
|
|
upperBound: 2 * firstBucketBound,
|
|
},
|
|
{
|
|
sz: 2 * firstBucketBound,
|
|
upperBound: 2 * firstBucketBound,
|
|
},
|
|
{
|
|
sz: 2*firstBucketBound + 1,
|
|
upperBound: 4 * firstBucketBound,
|
|
},
|
|
} {
|
|
require.Equal(t, bucketKeyFromBounds(item.upperBound), bucketForSize(item.sz))
|
|
}
|
|
}
|
|
|
|
func BenchmarkUpperBound(b *testing.B) {
|
|
for _, size := range []uint64{1, 1023, 65 * 1024, 40 * 1024 * 1024} {
|
|
b.Run(fmt.Sprintf("size=%d", size), func(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
_ = upperPowerOfTwo(size)
|
|
}
|
|
})
|
|
}
|
|
}
|