From 389e6eb70b0c68ffd533b07bfc24e496c3632541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 28 Jan 2021 18:15:22 +0100 Subject: [PATCH] state compute-state ---html --no-timing flag --- cli/state.go | 44 ++++++++++++------- testplans/lotus-soup/rfwp/html_chain_state.go | 2 +- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/cli/state.go b/cli/state.go index 5899dfdb12a..307db66680f 100644 --- a/cli/state.go +++ b/cli/state.go @@ -935,6 +935,10 @@ var stateComputeStateCmd = &cli.Command{ Name: "compute-state-output", Usage: "a json file containing pre-existing compute-state output, to generate html reports without rerunning state changes", }, + &cli.BoolFlag{ + Name: "no-timing", + Usage: "don't show timing information in html traces", + }, }, Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) @@ -1026,7 +1030,9 @@ var stateComputeStateCmd = &cli.Command{ return c.Code, nil } - return ComputeStateHTMLTempl(os.Stdout, ts, stout, getCode) + _, _ = fmt.Fprintln(os.Stderr, "computed state cid: ", stout.Root) + + return ComputeStateHTMLTempl(os.Stdout, ts, stout, !cctx.Bool("no-timing"), getCode) } fmt.Println("computed state cid: ", stout.Root) @@ -1147,8 +1153,11 @@ var compStateMsg = ` {{if gt (len .Msg.Params) 0}}
{{JsonParams ($code) (.Msg.Method) (.Msg.Params) | html}}
{{end}} -
Took {{.Duration}}, Exit: {{.MsgRct.ExitCode}}{{if gt (len .MsgRct.Return) 0}}, Return{{end}}
- + {{if PrintTiming}} +
Took {{.Duration}}, Exit: {{.MsgRct.ExitCode}}{{if gt (len .MsgRct.Return) 0}}, Return{{end}}
+ {{else}} +
Exit: {{.MsgRct.ExitCode}}{{if gt (len .MsgRct.Return) 0}}, Return{{end}}
+ {{end}} {{if gt (len .MsgRct.Return) 0}}
{{JsonReturn ($code) (.Msg.Method) (.MsgRct.Return) | html}}
{{end}} @@ -1174,7 +1183,7 @@ var compStateMsg = ` {{range .GasCharges}} {{.Name}}{{if .Extra}}:{{.Extra}}{{end}} {{template "gasC" .}} - {{.TimeTaken}} + {{if PrintTiming}}{{.TimeTaken}}{{end}} {{ $fImp := FirstImportant .Location }} {{ if $fImp }} @@ -1213,7 +1222,7 @@ var compStateMsg = ` {{with SumGas .GasCharges}} Sum {{template "gasC" .}} - {{.TimeTaken}} + {{if PrintTiming}}{{.TimeTaken}}{{end}} {{end}} @@ -1234,19 +1243,20 @@ type compStateHTMLIn struct { Comp *api.ComputeStateOutput } -func ComputeStateHTMLTempl(w io.Writer, ts *types.TipSet, o *api.ComputeStateOutput, getCode func(addr address.Address) (cid.Cid, error)) error { +func ComputeStateHTMLTempl(w io.Writer, ts *types.TipSet, o *api.ComputeStateOutput, printTiming bool, getCode func(addr address.Address) (cid.Cid, error)) error { t, err := template.New("compute_state").Funcs(map[string]interface{}{ - "GetCode": getCode, - "GetMethod": getMethod, - "ToFil": toFil, - "JsonParams": JsonParams, - "JsonReturn": jsonReturn, - "IsSlow": isSlow, - "IsVerySlow": isVerySlow, - "IntExit": func(i exitcode.ExitCode) int64 { return int64(i) }, - "SumGas": sumGas, - "CodeStr": codeStr, - "Call": call, + "GetCode": getCode, + "GetMethod": getMethod, + "ToFil": toFil, + "JsonParams": JsonParams, + "JsonReturn": jsonReturn, + "IsSlow": isSlow, + "IsVerySlow": isVerySlow, + "IntExit": func(i exitcode.ExitCode) int64 { return int64(i) }, + "SumGas": sumGas, + "CodeStr": codeStr, + "Call": call, + "PrintTiming": func() bool { return printTiming }, "FirstImportant": func(locs []types.Loc) *types.Loc { if len(locs) != 0 { for _, l := range locs { diff --git a/testplans/lotus-soup/rfwp/html_chain_state.go b/testplans/lotus-soup/rfwp/html_chain_state.go index bc39b58d22f..480d9fa16d1 100644 --- a/testplans/lotus-soup/rfwp/html_chain_state.go +++ b/testplans/lotus-soup/rfwp/html_chain_state.go @@ -55,7 +55,7 @@ func FetchChainState(t *testkit.TestEnvironment, m *testkit.LotusMiner) error { return c.Code, nil } - return cli.ComputeStateHTMLTempl(file, tipset, stout, getCode) + return cli.ComputeStateHTMLTempl(file, tipset, stout, true, getCode) }() if err != nil { return err