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) { func benchmarkHash(sszPath string, sszType string) {
switch sszType { switch sszType {
case "state_capella": case "state_capella":
data := &ethpb.BeaconStateCapella{} st := &ethpb.BeaconStateCapella{}
if err := dataFetcher(sszPath, data); err != nil { rawFile, err := os.ReadFile(sszPath) // #nosec G304
if err != nil {
log.Fatal(err) log.Fatal(err)
} }
startDeserialize := time.Now() startDeserialize := time.Now()
st, err := state_native.InitializeFromProtoCapella(data) if err := st.UnmarshalSSZ(rawFile); err != nil {
if err != nil { log.Fatal(err)
log.Fatal("not a state")
} }
deserializeDuration := time.Since(startDeserialize) deserializeDuration := time.Since(startDeserialize)
start := time.Now() start := time.Now()
root, err := st.HashTreeRoot(context.Background()) root, err := st.HashTreeRoot()
if err != nil { if err != nil {
log.Fatal("couldn't hash") log.Fatal("couldn't hash")
} }