github.com/criyle/go-sandbox@v0.10.3/runner/result.go (about) 1 package runner 2 3 import ( 4 "fmt" 5 "time" 6 ) 7 8 // Result is the program runner result 9 type Result struct { 10 Status // result status 11 ExitStatus int // exit status (signal number if signalled) 12 Error string // potential detailed error message (for program runner error) 13 14 Time time.Duration // used user CPU time (underlying type int64 in ns) 15 Memory Size // used user memory (underlying type uint64 in bytes) 16 17 // metrics for the program runner 18 SetUpTime time.Duration 19 RunningTime time.Duration 20 } 21 22 func (r Result) String() string { 23 switch r.Status { 24 case StatusNormal: 25 return fmt.Sprintf("Result[%v %v][%v %v]", r.Time, r.Memory, r.SetUpTime, r.RunningTime) 26 27 case StatusSignalled: 28 return fmt.Sprintf("Result[Signalled(%d)][%v %v][%v %v]", r.ExitStatus, r.Time, r.Memory, r.SetUpTime, r.RunningTime) 29 30 case StatusRunnerError: 31 return fmt.Sprintf("Result[RunnerFailed(%s)][%v %v][%v %v]", r.Error, r.Time, r.Memory, r.SetUpTime, r.RunningTime) 32 33 default: 34 return fmt.Sprintf("Result[%v(%s %d)][%v %v][%v %v]", r.Status, r.Error, r.ExitStatus, r.Time, r.Memory, r.SetUpTime, r.RunningTime) 35 } 36 }