dnsbench

package
v0.0.0-...-751d3d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNameserver = "8.8.8.8:53"
	DefaultTimeout    = time.Second * 5
)
View Source
const (
	// DefaultWorkers is the default initial worker count for a Runner.
	DefaultWorkers = 1
	// DefaultMaxWorkers is the default maximum worker count for a Runner.
	DefaultMaxWorkers = 10
)

Variables

This section is empty.

Functions

func MaxWorkers

func MaxWorkers(workers int) func(*Runner)

MaxWorkers returns an options function which sets the maximum worker count for a Runner.

func Nameserver

func Nameserver(ns string) func(*RemoteResolver)

func Timeout

func Timeout(timeout time.Duration) func(*RemoteResolver)

func Workers

func Workers(workers int) func(*Runner)

Workers returns an options function which sets the initial worker count for a Runner.

Types

type LocalResolver

type LocalResolver struct{}

func NewLocalResolver

func NewLocalResolver(opts ...func(*LocalResolver)) *LocalResolver

func (*LocalResolver) Resolve

func (r *LocalResolver) Resolve(name Namer) *Result

type Name

type Name struct {
	Name string
	Type uint16
}

type Namer

type Namer func() Name

func FileNamer

func FileNamer(file io.Reader) (Namer, error)

type RemoteResolver

type RemoteResolver struct {
	// contains filtered or unexported fields
}

func NewRemoteResolver

func NewRemoteResolver(opts ...func(*RemoteResolver)) *RemoteResolver

func (*RemoteResolver) Resolve

func (r *RemoteResolver) Resolve(name Namer) *Result

type Resolver

type Resolver interface {
	Resolve(name Namer) *Result
}

type Result

type Result struct {
	Duration time.Duration
	Error    error
}

Result records the diration and error state of a completed DNS request.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner is a benchmark runner for a Resolver.

func NewRunner

func NewRunner(resolver Resolver, opts ...func(*Runner)) *Runner

NewRunner returns a new Runner

func (*Runner) Begin

func (r *Runner) Begin() time.Time

Begin returns the time the test was started.

func (*Runner) End

func (r *Runner) End() time.Time

End returns the time the test wast stopped.

func (*Runner) NumWorkers

func (r *Runner) NumWorkers() int

NumWorkers returns the number of active workers.

func (*Runner) Start

func (r *Runner) Start(names Namer, qps int, count int) <-chan *Result

Start initiates a benchmark run using the provided Namer, QPS target, and total request count.

func (*Runner) Stop

func (r *Runner) Stop()

Stop shuts down a running test.

type TextReporter

type TextReporter struct {
	// contains filtered or unexported fields
}

TextReporter is a reporter that writes simple text formatted information intented for human reading.

func NewTextReporter

func NewTextReporter(w io.Writer, start time.Time, interval time.Duration) *TextReporter

NewTextReporter returns a new TextReporter

func (*TextReporter) Display

func (r *TextReporter) Display()

Display writes interval statistics to the configured output destination.

func (*TextReporter) Heading

func (r *TextReporter) Heading()

Heading writes the report heading.

func (*TextReporter) NewInterval

func (r *TextReporter) NewInterval()

NewInterval resets the current interval statistics.

func (*TextReporter) Summary

func (r *TextReporter) Summary(run *Runner)

Summary writes end of run details.

func (*TextReporter) Update

func (r *TextReporter) Update(res *Result)

Update records a new result.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL