Merge pull request #5470 from filecoin-project/feat/no-timing-compute-state

state compute-state ---html --no-timing flag
This commit is contained in:
Łukasz Magiera 2021-01-30 11:23:21 +01:00 committed by GitHub
commit d9e0d474d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 18 deletions

View File

@ -935,6 +935,10 @@ var stateComputeStateCmd = &cli.Command{
Name: "compute-state-output", Name: "compute-state-output",
Usage: "a json file containing pre-existing compute-state output, to generate html reports without rerunning state changes", 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 { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
@ -1026,7 +1030,9 @@ var stateComputeStateCmd = &cli.Command{
return c.Code, nil 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) fmt.Println("computed state cid: ", stout.Root)
@ -1147,8 +1153,11 @@ var compStateMsg = `
{{if gt (len .Msg.Params) 0}} {{if gt (len .Msg.Params) 0}}
<div><pre class="params">{{JsonParams ($code) (.Msg.Method) (.Msg.Params) | html}}</pre></div> <div><pre class="params">{{JsonParams ($code) (.Msg.Method) (.Msg.Params) | html}}</pre></div>
{{end}} {{end}}
{{if PrintTiming}}
<div><span class="slow-{{IsSlow .Duration}}-{{IsVerySlow .Duration}}">Took {{.Duration}}</span>, <span class="exit{{IntExit .MsgRct.ExitCode}}">Exit: <b>{{.MsgRct.ExitCode}}</b></span>{{if gt (len .MsgRct.Return) 0}}, Return{{end}}</div> <div><span class="slow-{{IsSlow .Duration}}-{{IsVerySlow .Duration}}">Took {{.Duration}}</span>, <span class="exit{{IntExit .MsgRct.ExitCode}}">Exit: <b>{{.MsgRct.ExitCode}}</b></span>{{if gt (len .MsgRct.Return) 0}}, Return{{end}}</div>
{{else}}
<div><span class="exit{{IntExit .MsgRct.ExitCode}}">Exit: <b>{{.MsgRct.ExitCode}}</b></span>{{if gt (len .MsgRct.Return) 0}}, Return{{end}}</div>
{{end}}
{{if gt (len .MsgRct.Return) 0}} {{if gt (len .MsgRct.Return) 0}}
<div><pre class="ret">{{JsonReturn ($code) (.Msg.Method) (.MsgRct.Return) | html}}</pre></div> <div><pre class="ret">{{JsonReturn ($code) (.Msg.Method) (.MsgRct.Return) | html}}</pre></div>
{{end}} {{end}}
@ -1174,7 +1183,7 @@ var compStateMsg = `
{{range .GasCharges}} {{range .GasCharges}}
<tr><td>{{.Name}}{{if .Extra}}:{{.Extra}}{{end}}</td> <tr><td>{{.Name}}{{if .Extra}}:{{.Extra}}{{end}}</td>
{{template "gasC" .}} {{template "gasC" .}}
<td>{{.TimeTaken}}</td> <td>{{if PrintTiming}}{{.TimeTaken}}{{end}}</td>
<td> <td>
{{ $fImp := FirstImportant .Location }} {{ $fImp := FirstImportant .Location }}
{{ if $fImp }} {{ if $fImp }}
@ -1213,7 +1222,7 @@ var compStateMsg = `
{{with SumGas .GasCharges}} {{with SumGas .GasCharges}}
<tr class="sum"><td><b>Sum</b></td> <tr class="sum"><td><b>Sum</b></td>
{{template "gasC" .}} {{template "gasC" .}}
<td>{{.TimeTaken}}</td> <td>{{if PrintTiming}}{{.TimeTaken}}{{end}}</td>
<td></td></tr> <td></td></tr>
{{end}} {{end}}
</table> </table>
@ -1234,7 +1243,7 @@ type compStateHTMLIn struct {
Comp *api.ComputeStateOutput 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{}{ t, err := template.New("compute_state").Funcs(map[string]interface{}{
"GetCode": getCode, "GetCode": getCode,
"GetMethod": getMethod, "GetMethod": getMethod,
@ -1247,6 +1256,7 @@ func ComputeStateHTMLTempl(w io.Writer, ts *types.TipSet, o *api.ComputeStateOut
"SumGas": sumGas, "SumGas": sumGas,
"CodeStr": codeStr, "CodeStr": codeStr,
"Call": call, "Call": call,
"PrintTiming": func() bool { return printTiming },
"FirstImportant": func(locs []types.Loc) *types.Loc { "FirstImportant": func(locs []types.Loc) *types.Loc {
if len(locs) != 0 { if len(locs) != 0 {
for _, l := range locs { for _, l := range locs {

View File

@ -55,7 +55,7 @@ func FetchChainState(t *testkit.TestEnvironment, m *testkit.LotusMiner) error {
return c.Code, nil return c.Code, nil
} }
return cli.ComputeStateHTMLTempl(file, tipset, stout, getCode) return cli.ComputeStateHTMLTempl(file, tipset, stout, true, getCode)
}() }()
if err != nil { if err != nil {
return err return err