fix: benchmark deserialize without clone and init trie (#12626)

* fix: benchmark deserialize without clone

* remove tree initialization

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terencechain 2023-07-15 05:35:58 -07:00 committed by GitHub
parent af0ee9bd16
commit 7e474b7a30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,18 +269,20 @@ func prettyPrint(sszPath string, data fssz.Unmarshaler) {
func benchmarkHash(sszPath string, sszType string) {
switch sszType {
case "state_capella":
data := &ethpb.BeaconStateCapella{}
if err := dataFetcher(sszPath, data); err != nil {
st := &ethpb.BeaconStateCapella{}
rawFile, err := os.ReadFile(sszPath) // #nosec G304
if err != nil {
log.Fatal(err)
}
startDeserialize := time.Now()
st, err := state_native.InitializeFromProtoCapella(data)
if err != nil {
log.Fatal("not a state")
if err := st.UnmarshalSSZ(rawFile); err != nil {
log.Fatal(err)
}
deserializeDuration := time.Since(startDeserialize)
start := time.Now()
root, err := st.HashTreeRoot(context.Background())
root, err := st.HashTreeRoot()
if err != nil {
log.Fatal("couldn't hash")
}