Documentation
¶
Overview ¶
Package workload is what the benchmarks' guests do: the programs they run, how to tell they are ready, and the requests sent to them.
A workload is separate from what a scenario measures, so that a fleet, a fork fan-out and a standby can all run the same guests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LoadGenerator ¶
type LoadGenerator struct {
// contains filtered or unexported fields
}
LoadGenerator sends each guest's service requests at a fixed rate and records how long they take.
The rate is kept whatever the guests do: each request is due at a set time, and its latency is counted from then, not from when it was sent. A guest that falls behind is charged for the requests that queued behind a slow one, which a sender that waited for each response would hide.
It is safe for concurrent use.
func NewLoadGenerator ¶
func NewLoadGenerator(requestsPerSecond float64) *LoadGenerator
NewLoadGenerator returns a generator sending requestsPerSecond to each guest it is given.
func (*LoadGenerator) Add ¶
func (g *LoadGenerator) Add(ctx context.Context, url string)
Add starts sending requests to url until ctx is done.
func (*LoadGenerator) Take ¶
func (g *LoadGenerator) Take() ([]time.Duration, int)
Take returns the latencies and failures recorded since it was last called.
func (*LoadGenerator) Wait ¶
func (g *LoadGenerator) Wait()
Wait blocks until every guest's sender has stopped, once their contexts are done.
type Workload ¶
type Workload struct {
// Name says what the workload is, in the results.
Name string
// Image is the image it runs in.
Image string
// Cmd and Env are the guest's command and its environment.
Cmd []string
Env map[string]string
// Port is where its HTTP service answers, or 0 if it has none: it is
// then ready once a command can run in its guest.
Port int
}
Workload is a guest's program.
func Idle ¶
Idle returns an HTTP service, in an image with Python 3, that holds no more than the interpreter and answers each request with "ok": a sandbox or a development environment waiting for someone to use it.
func Job ¶
Job returns a batch job, in an image with Python 3, that works through mib of data, then rests for rest, over and over: a guest that is busy some of the time.