All checks were successful
* Add plugin option for protogen in Makefile * Fix the generator for the plugin in util/protogen * Erase convertable types, move helpful methods to gRPC protobufs * Erase helpers for convertations * Generate StableMarshlal/StableSize for protobufs by the protoc plugin Signed-off-by: Airat Arifullin a.arifullin@yadro.com
41 lines
840 B
Go
41 lines
840 B
Go
package refs
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
|
|
refstest "git.frostfs.info/TrueCloudLab/aarifullin/v2/refs/test"
|
|
"git.frostfs.info/TrueCloudLab/aarifullin/v2/util/proto"
|
|
)
|
|
|
|
func BenchmarkObjectIDSlice(b *testing.B) {
|
|
for _, size := range []int{0, 1, 50} {
|
|
b.Run(strconv.Itoa(size)+" elements", func(b *testing.B) {
|
|
benchmarkObjectIDSlice(b, size)
|
|
})
|
|
}
|
|
}
|
|
|
|
func benchmarkObjectIDSlice(b *testing.B, size int) {
|
|
ids := refstest.GenerateObjectIDs(false)
|
|
|
|
b.Run("marshal", func(b *testing.B) {
|
|
b.ReportAllocs()
|
|
for i := 0; i < b.N; i++ {
|
|
size := 0
|
|
for _, id := range ids {
|
|
size += proto.NestedStructureSize(9, id)
|
|
}
|
|
|
|
buf := make([]byte, size)
|
|
offset := 0
|
|
for _, id := range ids {
|
|
offset += proto.NestedStructureMarshal(9, buf[offset:], id)
|
|
}
|
|
|
|
if offset != len(buf) {
|
|
b.FailNow()
|
|
}
|
|
}
|
|
})
|
|
}
|