Print JSON instead of raw Go structs for -debug.print-events

This commit is contained in:
Joël Stemmer
2022-03-20 22:43:51 +00:00
parent 9e3af115d3
commit 26cb3d5eb3
2 changed files with 20 additions and 16 deletions

View File

@ -2,24 +2,24 @@ package gotest
import "time"
// Event is a single event in a test or benchmark.
// Event is a single event in a Go test or benchmark.
type Event struct {
Type string
Type string `json:"type"`
Name string
Result string
Duration time.Duration
Data string
Indent int
Name string `json:"name,omitempty"`
Result string `json:"result,omitempty"`
Duration time.Duration `json:"duration,omitempty"`
Data string `json:"data,omitempty"`
Indent int `json:"indent,omitempty"`
// Code coverage
CovPct float64
CovPackages []string
CovPct float64 `json:"coverage_percentage,omitempty"`
CovPackages []string `json:"coverage_packages,omitempty"`
// Benchmarks
Iterations int64
NsPerOp float64
MBPerSec float64
BytesPerOp int64
AllocsPerOp int64
Iterations int64 `json:"benchmark_iterations,omitempty"`
NsPerOp float64 `json:"benchmark_ns_per_op,omitempty"`
MBPerSec float64 `json:"benchmark_mb_per_sec,omitempty"`
BytesPerOp int64 `json:"benchmark_bytes_per_op,omitempty"`
AllocsPerOp int64 `json:"benchmark_allocs_per_op,omitempty"`
}