From 4a7e30a5436df2c4a438438da5c41bc6419deb92 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Sat, 2 Nov 2024 21:02:22 -0500 Subject: [PATCH] Benchmark process slots --- .../core/transition/transition_test.go | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/beacon-chain/core/transition/transition_test.go b/beacon-chain/core/transition/transition_test.go index 9000afeee603..c03bdbafdc5a 100644 --- a/beacon-chain/core/transition/transition_test.go +++ b/beacon-chain/core/transition/transition_test.go @@ -698,3 +698,45 @@ func TestProcessSlotsConditionally(t *testing.T) { assert.Equal(t, primitives.Slot(6), s.Slot()) }) } + +func BenchmarkProcessSlots_Capella(b *testing.B) { + st, _ := util.DeterministicGenesisStateCapella(b, params.BeaconConfig().MaxValidatorsPerCommittee) + + var err error + + b.ResetTimer() + for i := 0; i < b.N; i++ { + st, err = transition.ProcessSlots(context.Background(), st, st.Slot()+1) + if err != nil { + b.Fatalf("Failed to process slot %v", err) + } + } +} + +func BenchmarkProcessSlots_Deneb(b *testing.B) { + st, _ := util.DeterministicGenesisStateDeneb(b, params.BeaconConfig().MaxValidatorsPerCommittee) + + var err error + + b.ResetTimer() + for i := 0; i < b.N; i++ { + st, err = transition.ProcessSlots(context.Background(), st, st.Slot()+1) + if err != nil { + b.Fatalf("Failed to process slot %v", err) + } + } +} + +func BenchmarkProcessSlots_Electra(b *testing.B) { + st, _ := util.DeterministicGenesisStateElectra(b, params.BeaconConfig().MaxValidatorsPerCommittee) + + var err error + + b.ResetTimer() + for i := 0; i < b.N; i++ { + st, err = transition.ProcessSlots(context.Background(), st, st.Slot()+1) + if err != nil { + b.Fatalf("Failed to process slot %v", err) + } + } +}