From 12cd478e11c5ee6e1eadab98392710c379f1f93a Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 7 Oct 2020 15:14:46 -0700 Subject: [PATCH] Add message counts to inspect chain output --- cli/chain.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cli/chain.go b/cli/chain.go index 20a8b7797..763752f23 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -449,11 +449,16 @@ var chainInspectUsage = &cli.Command{ bySender := make(map[string]int64) byDest := make(map[string]int64) byMethod := make(map[string]int64) + bySenderC := make(map[string]int64) + byDestC := make(map[string]int64) + byMethodC := make(map[string]int64) var sum int64 for _, m := range msgs { bySender[m.Message.From.String()] += m.Message.GasLimit + bySenderC[m.Message.From.String()]++ byDest[m.Message.To.String()] += m.Message.GasLimit + byDestC[m.Message.To.String()]++ sum += m.Message.GasLimit code, err := lookupActorCode(m.Message.To) @@ -464,7 +469,7 @@ var chainInspectUsage = &cli.Command{ mm := stmgr.MethodsMap[code][m.Message.Method] byMethod[mm.Name] += m.Message.GasLimit - + byMethodC[mm.Name]++ } type keyGasPair struct { @@ -496,19 +501,19 @@ var chainInspectUsage = &cli.Command{ fmt.Printf("By Sender:\n") for i := 0; i < numRes && i < len(senderVals); i++ { sv := senderVals[i] - fmt.Printf("%s\t%0.2f%%\t(%d)\n", sv.Key, (100*float64(sv.Gas))/float64(sum), sv.Gas) + fmt.Printf("%s\t%0.2f%%\t(total: %d, count: %d)\n", sv.Key, (100*float64(sv.Gas))/float64(sum), sv.Gas, bySenderC[sv.Key]) } fmt.Println() fmt.Printf("By Receiver:\n") for i := 0; i < numRes && i < len(destVals); i++ { sv := destVals[i] - fmt.Printf("%s\t%0.2f%%\t(%d)\n", sv.Key, (100*float64(sv.Gas))/float64(sum), sv.Gas) + fmt.Printf("%s\t%0.2f%%\t(total: %d, count: %d)\n", sv.Key, (100*float64(sv.Gas))/float64(sum), sv.Gas, byDestC[sv.Key]) } fmt.Println() fmt.Printf("By Method:\n") for i := 0; i < numRes && i < len(methodVals); i++ { sv := methodVals[i] - fmt.Printf("%s\t%0.2f%%\t(%d)\n", sv.Key, (100*float64(sv.Gas))/float64(sum), sv.Gas) + fmt.Printf("%s\t%0.2f%%\t(total: %d, count: %d)\n", sv.Key, (100*float64(sv.Gas))/float64(sum), sv.Gas, byMethodC[sv.Key]) } return nil