mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
Allocate the appropriate memory for retrieveIndicesFromBitfield (#6507)
* Allocate the appropriate memory for retrieveIndicesFromBitfield * Merge refs/heads/master into memory0 * Merge refs/heads/master into memory0 * Merge refs/heads/master into memory0 * Merge refs/heads/master into memory0 * Merge refs/heads/master into memory0 * Merge refs/heads/master into memory0 * Merge refs/heads/master into memory0
This commit is contained in:
parent
fd9003f822
commit
a02553815f
@ -22,7 +22,10 @@ go_library(
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["status_test.go"],
|
||||
srcs = [
|
||||
"benchmark_test.go",
|
||||
"status_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
|
18
beacon-chain/p2p/peers/benchmark_test.go
Normal file
18
beacon-chain/p2p/peers/benchmark_test.go
Normal file
@ -0,0 +1,18 @@
|
||||
package peers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
)
|
||||
|
||||
func Benchmark_retrieveIndicesFromBitfield(b *testing.B) {
|
||||
bv := bitfield.NewBitvector64()
|
||||
for i := uint64(0); i < bv.Len(); i++ {
|
||||
bv.SetBitAt(i, true)
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
retrieveIndicesFromBitfield(bv)
|
||||
}
|
||||
}
|
@ -493,7 +493,7 @@ func (p *Status) HighestEpoch() uint64 {
|
||||
}
|
||||
|
||||
func retrieveIndicesFromBitfield(bitV bitfield.Bitvector64) []uint64 {
|
||||
committeeIdxs := []uint64{}
|
||||
committeeIdxs := make([]uint64, 0, bitV.Count())
|
||||
for i := uint64(0); i < 64; i++ {
|
||||
if bitV.BitAt(i) {
|
||||
committeeIdxs = append(committeeIdxs, i)
|
||||
|
Loading…
Reference in New Issue
Block a user