mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 02:31:19 +00:00
5a66807989
* First take at updating everything to v5 * Patch gRPC gateway to use prysm v5 Fix patch * Update go ssz --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package state_native_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
|
"github.com/prysmaticlabs/prysm/v5/config/params"
|
|
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
|
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
|
)
|
|
|
|
func BenchmarkAppendHistoricalRoots(b *testing.B) {
|
|
st, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{})
|
|
require.NoError(b, err)
|
|
|
|
max := params.BeaconConfig().HistoricalRootsLimit
|
|
if max < 2 {
|
|
b.Fatalf("HistoricalRootsLimit is less than 2: %d", max)
|
|
}
|
|
|
|
root := bytesutil.ToBytes32([]byte{0, 1, 2, 3, 4, 5})
|
|
for i := uint64(0); i < max-2; i++ {
|
|
err := st.AppendHistoricalRoots(root)
|
|
require.NoError(b, err)
|
|
}
|
|
|
|
ref := st.Copy()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
err := ref.AppendHistoricalRoots(root)
|
|
require.NoError(b, err)
|
|
ref = st.Copy()
|
|
}
|
|
}
|
|
|
|
func BenchmarkAppendHistoricalSummaries(b *testing.B) {
|
|
st, err := state_native.InitializeFromProtoCapella(ðpb.BeaconStateCapella{})
|
|
require.NoError(b, err)
|
|
|
|
max := params.BeaconConfig().HistoricalRootsLimit
|
|
if max < 2 {
|
|
b.Fatalf("HistoricalRootsLimit is less than 2: %d", max)
|
|
}
|
|
|
|
for i := uint64(0); i < max-2; i++ {
|
|
err := st.AppendHistoricalSummaries(ðpb.HistoricalSummary{})
|
|
require.NoError(b, err)
|
|
}
|
|
|
|
ref := st.Copy()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
err := ref.AppendHistoricalSummaries(ðpb.HistoricalSummary{})
|
|
require.NoError(b, err)
|
|
ref = st.Copy()
|
|
}
|
|
}
|