mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
f812bdcf60
* beacon-chain/state/attenstation: alloc +1 items for append Signed-off-by: jsvisa <delweng@gmail.com> * beacon-chain/state/eth1: alloc +1 items for append Signed-off-by: jsvisa <delweng@gmail.com> * beacon-chain/state/misc: alloc +1 items for append Signed-off-by: jsvisa <delweng@gmail.com> * beacon-chain/state/participation: alloc +1 items for append Signed-off-by: jsvisa <delweng@gmail.com> * beacon-chain/state/validator: alloc +1 items for append Signed-off-by: jsvisa <delweng@gmail.com> * Add some benchmarks * Evaluate append vs copy. Apply results * fix copy issue * revert copy changes from a5ba8d4352f647ad384981264cb6e0553481f23b --------- Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package state_native_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native"
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
|
)
|
|
|
|
func BenchmarkAppendBalance(b *testing.B) {
|
|
st, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{})
|
|
require.NoError(b, err)
|
|
|
|
max := uint64(16777216)
|
|
for i := uint64(0); i < max-2; i++ {
|
|
require.NoError(b, st.AppendBalance(i))
|
|
}
|
|
|
|
ref := st.Copy()
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
require.NoError(b, ref.AppendBalance(uint64(i)))
|
|
ref = st.Copy()
|
|
}
|
|
}
|
|
|
|
func BenchmarkAppendInactivityScore(b *testing.B) {
|
|
st, err := state_native.InitializeFromProtoCapella(ðpb.BeaconStateCapella{})
|
|
require.NoError(b, err)
|
|
|
|
max := uint64(16777216)
|
|
for i := uint64(0); i < max-2; i++ {
|
|
require.NoError(b, st.AppendInactivityScore(i))
|
|
}
|
|
|
|
ref := st.Copy()
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
require.NoError(b, ref.AppendInactivityScore(uint64(i)))
|
|
ref = st.Copy()
|
|
}
|
|
}
|