prysm-pulse/beacon-chain/state/stateutil/validator_root_test.go
Preston Van Loon 3767574c77
stateutil: Reduce allocations by specifying slice capacity eager (#9977)
* Reduce allocations by specifying slice capacity eager

* gofmt
2021-12-03 09:06:05 +00:00

23 lines
466 B
Go

package stateutil_test
import (
"testing"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
)
func BenchmarkUint64ListRootWithRegistryLimit(b *testing.B) {
balances := make([]uint64, 100000)
for i := 0; i < len(balances); i++ {
balances[i] = uint64(i)
}
b.Run("100k balances", func(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := stateutil.Uint64ListRootWithRegistryLimit(balances)
if err != nil {
b.Fatal(err)
}
}
})
}