frostfs-sdk-go/netmap/bench_test.go
Dmitrii Stepanov 56debcfa56
All checks were successful
DCO / DCO (pull_request) Successful in 56s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m16s
Tests and linters / Tests (1.20) (pull_request) Successful in 1m13s
Tests and linters / Lint (pull_request) Successful in 2m20s
[#190] sdk-go: Gofumpt fixes
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-11-22 19:21:20 +03:00

58 lines
1.7 KiB
Go

package netmap
import (
"testing"
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
"github.com/stretchr/testify/require"
)
func BenchmarkNetmap_ContainerNodes(b *testing.B) {
nodes := []NodeInfo{
nodeInfoFromAttributes("Country", "Russia", "Order", "1"),
nodeInfoFromAttributes("Country", "Germany", "Order", "2"),
nodeInfoFromAttributes("Country", "Russia", "Order", "3"),
nodeInfoFromAttributes("Country", "France", "Order", "4"),
nodeInfoFromAttributes("Country", "France", "Order", "5"),
nodeInfoFromAttributes("Country", "Russia", "Order", "6"),
nodeInfoFromAttributes("Country", "Russia", "Order", "7"),
nodeInfoFromAttributes("Country", "Germany", "Order", "8"),
nodeInfoFromAttributes("Country", "Germany", "Order", "9"),
nodeInfoFromAttributes("Country", "Russia", "Order", "10"),
nodeInfoFromAttributes("Country", "China", "Order", "11"),
nodeInfoFromAttributes("Country", "China", "Order", "12"),
nodeInfoFromAttributes("Country", "Finland", "Order", "13"),
nodeInfoFromAttributes("Country", "Finland", "Order", "14"),
nodeInfoFromAttributes("Country", "España", "Order", "15"),
nodeInfoFromAttributes("Country", "España", "Order", "16"),
}
var nm NetMap
nm.SetNodes(nodes)
policies := []string{
`REP 2`,
`REP 2 IN X CBF 2 SELECT 2 FROM * AS X`,
}
cnr := cidtest.ID()
pivot := make([]byte, 32)
cnr.Encode(pivot)
for i := range policies {
b.Run(policies[i], func(b *testing.B) {
var p PlacementPolicy
require.NoError(b, p.DecodeString(policies[i]))
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, err := nm.ContainerNodes(p, pivot)
if err != nil {
b.Fatal(err)
}
}
})
}
}