[#168] netmap: Add simple selector benchmark

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2022-03-11 12:18:41 +03:00 committed by Alex Vanin
parent b91e25f782
commit 7d19718e1d

View file

@ -80,3 +80,27 @@ func TestPlacementPolicy_Interopability(t *testing.T) {
})
}
}
func BenchmarkManySelects(b *testing.B) {
testsFile := filepath.Join("json_tests", "many_selects.json")
bs, err := ioutil.ReadFile(testsFile)
require.NoError(b, err)
var tc TestCase
require.NoError(b, json.Unmarshal(bs, &tc))
tt, ok := tc.Tests["Select"]
require.True(b, ok)
nodes := NodesFromInfo(tc.Nodes)
nm, err := NewNetmap(nodes)
require.NoError(b, err)
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, err = nm.GetContainerNodes(&tt.Policy, tt.Pivot)
if err != nil {
b.FailNow()
}
}
}