feat(parser/resultdetail): human readable units
All checks were successful
build / build (push) Successful in 1m2s
build / trigger-build-image (push) Successful in 11s

This commit is contained in:
张泊明518370910136 2024-10-12 17:24:14 -04:00
parent d934e9a067
commit 5f63301656
GPG Key ID: D47306D7062CDA9D

View File

@ -29,21 +29,21 @@ func (*ResultDetail) Run(results []stage.ExecutorResult, confAny any) (
var res []stage.ParserResult var res []stage.ParserResult
for _, result := range results { for _, result := range results {
comment := "" comment := ""
// TODO: more human readable units
if conf.ShowExitStatus { if conf.ShowExitStatus {
comment += fmt.Sprintf("Exit Status: %d\n", result.ExitStatus) comment += fmt.Sprintf("Exit Status: `%d`\n", result.ExitStatus)
} }
if conf.ShowError { if conf.ShowError {
comment += fmt.Sprintf("Error: %s\n", result.Error) comment += fmt.Sprintf("Error: `%s`\n", result.Error)
} }
if conf.ShowTime { if conf.ShowTime {
comment += fmt.Sprintf("Time: %d\n", result.Time) comment += fmt.Sprintf("Time: `%d ms`\n", result.Time/1e9)
} }
if conf.ShowMemory { if conf.ShowMemory {
comment += fmt.Sprintf("Memory: %d\n", result.Memory) comment += fmt.Sprintf("Memory: `%.2f MiB`\n",
float64(result.Memory)/(1024*1024))
} }
if conf.ShowRunTime { if conf.ShowRunTime {
comment += fmt.Sprintf("RunTime: %d\n", result.RunTime) comment += fmt.Sprintf("RunTime: `%d ms`\n", result.RunTime/1e9)
} }
for _, file := range conf.ShowFiles { for _, file := range conf.ShowFiles {
content, ok := result.Files[file] content, ok := result.Files[file]