From 945c76132c40193e224fac90920fd455b3d58017 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Thu, 20 Jul 2023 16:49:17 +0800 Subject: [PATCH] Add Allocation Data To Benchmark (#12641) * add more data * terence's review --- tools/pcli/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/pcli/main.go b/tools/pcli/main.go index 30309275a..3a9d3b545 100644 --- a/tools/pcli/main.go +++ b/tools/pcli/main.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "regexp" + "runtime" "strings" "time" @@ -286,11 +287,16 @@ func benchmarkHash(sszPath string, sszType string) { log.Fatal(err) } start := time.Now() + stat := &runtime.MemStats{} + runtime.ReadMemStats(stat) root, err := stateTrieState.HashTreeRoot(context.Background()) if err != nil { log.Fatal("couldn't hash") } + newStat := &runtime.MemStats{} + runtime.ReadMemStats(newStat) fmt.Printf("Deserialize Duration: %v, Hashing Duration: %v HTR: %#x\n", deserializeDuration, time.Since(start), root) + fmt.Printf("Total Memory Allocation Differential: %d bytes, Heap Memory Allocation Differential: %d bytes\n", int64(newStat.TotalAlloc)-int64(stat.TotalAlloc), int64(newStat.HeapAlloc)-int64(stat.HeapAlloc)) return default: log.Fatal("Invalid type")