-
Notifications
You must be signed in to change notification settings - Fork 1
IO Structures
Thomas Moreira edited this page Oct 14, 2022
·
30 revisions
client → engine
// Config is the global configuration for a Benchttp Run
type Config struct {
Request struct {
Method string
URL *url.URL
Header http.Header
Body Body
}
Runner struct {
Requests int
Concurrency int
Interval time.Duration
RequestTimeout time.Duration
GlobalTimeout time.Duration
}
Tests []struct {
Name string
Field metrics.Field
Predicate Predicate
Target metrics.Value
}
}request:
method: GET # string
url: https://a.b.com # string
queryParams: # Map<string, string>
key: value # key-value pair, key is a string, value is a valid encoded query parameters
header: # Map<string, string[]>
key0: [val0, val1]
key1: [val0]
body:
type: raw # only "raw" accepted
content: '{"key0":"val0","key1":"val1"}' # string
runner:
requests: 100 # number (integer)
concurrency: 1 # number (integer)
interval: 50ms # string (Go parsable time.Duration)
requestTimeout: 2s # string (Go parsable time.Duration)
globalTimeout: 60s # string (Go parsable time.Duration)
tests:
- name: minimum response time # string
field: ResponseTimes.Min # See available fields in the Wiki
predicate: GT # EQ | NEQ | GT | GTE | LT | LTE
target: 80ms # number (int) | string (Go parsable time.Duration)
- name: maximum response time
field: ResponseTimes.Max
predicate: LTE
target: 120ms
- name: 100% availability
field: RequestFailureCount
predicate: EQ
target: 0
engine → client
// RunReport is the overall result of a Benchttp run.
type RunReport struct {
// Metrics is an aggregate of metrics
// from recorded request results.
Metrics struct {
ResponseTimes TimeStats
RequestEventTimes map[string]TimeStats
StatusCodesDistribution map[int]int
Records []struct{ ResponseTime time.Duration }
RequestFailures []struct{ Reason string }
}
// Tests is the result of the tests ran on the metrics.
Tests struct {
Pass bool
Results []struct {
Input tests.Case
Pass bool
Summary string
}
}
// Metadata gathers meta information about the Run.
Metadata struct {
Config config.Global
FinishedAt time.Time
TotalDuration time.Duration
// TODO:
// RunEvents []struct {
// Name string // or "Type"
// Time time.Time
// }
// Hardware struct{}
}
}
type TimeStats struct{
Min, Max, Mean, Median, StdDev time.Duration
Deciles []time.Duration
Quartiles []time.Duration
}engine → client
// RunProgress represents the progression of a benchmark at a given time.
type RunProgress struct {
// Done reflects whether the run is over
Done bool
// Error reflects any internal error occurring during the run
Error error
// DoneCount is the current count of requests done
DoneCount int
// MaxCount is the maximum number of requests to do
// (equal to Config.Runner.Requests)
MaxCount int
// Timeout is the global timeout for the run
// (equal to Config.Runner.GlobalTimeout)
Timeout time.Duration
// Elapsed is the time elapsed since the run started
Elapsed time.Duration
}