From 2dce5ae65c5e16992a32c00c8d53952bbff45cc2 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 14 Dec 2019 15:19:08 +0000 Subject: [PATCH] executor: vmstats in json --- executor/executor.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/executor/executor.go b/executor/executor.go index 7c84d58..64cccaa 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -1,6 +1,7 @@ package executor import ( + "encoding/json" "errors" "fmt" "io" @@ -33,13 +34,25 @@ type Config struct { } type Result struct { - Status int64 - GasUsed uint64 - SyscallCount int64 - ExecDur time.Duration - PagesBeforeExec int - PagesUsed int - StartTime time.Time + Status int64 `json:"status"` + GasUsed uint64 `json:"gas_used"` + SyscallCount int64 `json:"syscall_count"` + ExecDur time.Duration `json:"exec_dur"` + PagesBeforeExec int `json:"pages_before_exec"` + PagesUsed int `json:"pages_used"` + StartTime time.Time `json:"start_time"` +} + +func (r Result) StatsJSONFile() txtar.File { + data, err := json.MarshalIndent(r, "", " ") + if err != nil /* unlikely */ { + panic(err) + } + + return txtar.File{ + Name: "vmstats.json", + Data: data, + } } func (r Result) StatsFile() txtar.File {