See Go's text/template package documentation
{
Benchmark {
Length int
Success int
Fail int
Duration time.Duration
Records []{
Time time.Duration
Code int
Bytes int
Error string
Events []{
Name string
Time time.Duration
}
}
}
Metadata {
Config {
Request {
Method string
URL *url.URL
Header http.Header
Body Body
}
Runner {
Requests int
Concurrency int
Interval time.Duration
RequestTimeout time.Duration
GlobalTimeout time.Duration
}
Output {
Out []string
Silent bool
Template string
}
}
FinishedAt time.Time
}
}
-
stats
:{{ stats.Min }}
: Minimum recorded request time{{ stats.Max }}
: Maximum recorded request time{{ stats.Mean }}
: Mean request time
-
fail
:{{ fail }}
: Fails the test and exit 1 (better used in a condition!){{ fail "Too long!" }}
: Same with error message
-
Custom summary
template: | {{ .Benchmark.Length }}/{{ .Metadata.Config.Runner.Requests }} requests {{ .Benchmark.Fail }} errors ✔︎ Done in {{ .Benchmark.Duration.Milliseconds }}ms.
100/100 requests 0 errors ✔︎ Done in 2034ms.
-
Display only the average request time
template: '{{ stats.Mean }}'
237ms
-
Fail the test if any request exceeds 200ms
template: | {{- if ge stats.Max.Milliseconds 200 -}} {{ fail "TOO SLOW" }} {{- else -}} OK {{- end -}}
if max >= 200ms:
test failed: TOO SLOW exit status 1
else:
OK