Ekaterina Lebedeva
bd588fa2e5
All checks were successful
DCO action / DCO (pull_request) Successful in 41s
Tests and linters / Lint (pull_request) Successful in 1m11s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m11s
Tests and linters / Tests (1.23) (pull_request) Successful in 1m10s
Tests and linters / Tests with -race (pull_request) Successful in 1m23s
Since Go 1.22 a `for` statement with a `range` clause is able to iterate through integer values from zero to an upper limit. gopatch script: @@ var i, e expression @@ -for i := 0; i <= e - 1; i++ { +for i := range e { ... } @@ var i, e expression @@ -for i := 0; i <= e; i++ { +for i := range e + 1 { ... } @@ var i, e expression @@ -for i := 0; i < e; i++ { +for i := range e { ... } Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
51 lines
1 KiB
Go
51 lines
1 KiB
Go
package acl_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl"
|
|
aclGrpc "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl/grpc"
|
|
acltest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl/test"
|
|
)
|
|
|
|
func BenchmarkTable_ToGRPCMessage(b *testing.B) {
|
|
const size = 4
|
|
|
|
tb := new(acl.Table)
|
|
rs := make([]acl.Record, size)
|
|
for i := range rs {
|
|
fs := make([]acl.HeaderFilter, size)
|
|
for j := range fs {
|
|
fs[j] = *acltest.GenerateFilter(false)
|
|
}
|
|
ts := make([]acl.Target, size)
|
|
for j := range ts {
|
|
ts[j] = *acltest.GenerateTarget(false)
|
|
}
|
|
|
|
rs[i].SetFilters(fs)
|
|
rs[i].SetTargets(ts)
|
|
}
|
|
tb.SetRecords(rs)
|
|
|
|
raw := tb.ToGRPCMessage()
|
|
|
|
b.Run("to grpc message", func(b *testing.B) {
|
|
b.ReportAllocs()
|
|
for range b.N {
|
|
raw := tb.ToGRPCMessage()
|
|
if len(tb.GetRecords()) != len(raw.(*aclGrpc.EACLTable).Records) {
|
|
b.FailNow()
|
|
}
|
|
}
|
|
})
|
|
b.Run("from grpc message", func(b *testing.B) {
|
|
b.ReportAllocs()
|
|
for range b.N {
|
|
tb := new(acl.Table)
|
|
if tb.FromGRPCMessage(raw) != nil {
|
|
b.FailNow()
|
|
}
|
|
}
|
|
})
|
|
}
|