prysm-pulse/beacon-chain/sync/initial-sync/fsm_benchmark_test.go
terencechain d17996f8b0
Update to V4 🚀 (#12134)
* Update V3 from V4

* Fix build v3 -> v4

* Update ssz

* Update beacon_chain.pb.go

* Fix formatter import

* Update update-mockgen.sh comment to v4

* Fix conflicts. Pass build and tests

* Fix test
2023-03-17 18:52:56 +00:00

40 lines
925 B
Go

package initialsync
import (
"testing"
"github.com/prysmaticlabs/prysm/v4/testing/require"
)
func BenchmarkStateMachine_trigger(b *testing.B) {
sm := newStateMachineManager()
handlerFn := func(m *stateMachine, in interface{}) (id stateID, err error) {
response, ok := in.(*fetchRequestParams)
if !ok {
return 0, errInputNotFetchRequestParams
}
_ = response.count
return stateScheduled, nil
}
sm.addEventHandler(eventTick, stateNew, handlerFn)
sm.addEventHandler(eventTick, stateScheduled, handlerFn)
sm.addEventHandler(eventTick, stateDataParsed, handlerFn)
sm.addEventHandler(eventTick, stateSkipped, handlerFn)
sm.addEventHandler(eventTick, stateSent, handlerFn)
sm.addStateMachine(64)
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
data := &fetchRequestParams{
start: 23,
count: 32,
}
err := sm.machines[64].trigger(eventTick, data)
require.NoError(b, err)
}
}